Skip to content

Conflict with NumPy in test/test_stltypes.py #98

Open

Description

@chofchof

Running python -m pytest test/test_stltypes.py produces numerous error messages.

Although I haven’t identified the exact root cause, one workaround is to add the line import numpy as np immediately after line 2 (import sys).

Activity

  1. aaronj0 commented on Sep 15, 2026

    @aaronj0
    Collaborator

    Hi, thanks for the report.

    I cannot reproduce this so far on linux and the CI currently tests numpy 2.5.3. Note that test_stltypes.py already imports numpy in the corresponding tests (in favour of globally importing it):

    def test18_array_interface(self):
    """Test usage of __array__ from numpy"""
    import cppjit
    try:
    import numpy as np
    except ImportError:
    skip("numpy is not installed")

    One possibility is that two libstdc++ copies are reachable in your environment: importing cppjit first pins the older one for the whole process, and the global import numpy loads the newer libstdc++ that numpy was built against before cppjit can pin the old one. You can test this by now adding an import cppjit before import numpy (after import sys) which should retrigger the previous error messages.

    Can you share a snippet of the error messages and your environment config: OS and architecture, Python version, numpy version, and cppjit installation mode (source/pip)? With that info this should be quick to pin down.

  2. chofchof commented on Sep 15, 2026

    @chofchof
    Author

    @aaronj0, thanks for a detailed answer.

    One possibility is that two libstdc++ copies are reachable in your environment: importing cppjit first pins the older one for the whole process, and the global import numpy loads the newer libstdc++ that numpy was built against before cppjit can pin the old one. You can test this by now adding an import cppjit before import numpy (after import sys) which should retrigger the previous error messages.

    You were right. I do have two copies of libstdc++.so.6 - one from the OS (AlmaLinux 10) at /usr/lib64/libstdc++.so.6, and another from Conda $CONDA_PREFIX/lib/libstdc++.so.6. After adding import cppjit before import numpy, I was able to see the same error messages again.

    Can you share a snippet of the error messages and your environment config: OS and architecture, Python version, numpy version, and cppjit installation mode (source/pip)? With that info this should be quick to pin down.

    Sure. I installed cppjit following the "Development build (pip editable)" instructions from this GitHub page. Below are the details of my environment.

    $ uname -a
    Linux alma59 6.12.0-211.53.1.el10_2.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 11 07:00:06 EDT 2026 x86_64 GNU/Linux
    $ cat /etc/almalinux-release
    AlmaLinux release 10.2 (Lavender Lion)
    $ dnf grouplist installed
    ... (skip) ...
    Installed Groups:
       Container Management
       Development Tools
       Headless Management
    $ python --version
    Python 3.14.7
    $ which python
    ~/miniforge3/envs/llvm22/bin/python
    $ python -c 'import numpy; print(numpy.__version__)'
    2.5.3
    

    error_message.log

  3. self-assigned this
    on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions