Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Installation problems with numpy 2.0 #134

Open
ljlamarche opened this issue Jun 24, 2024 · 2 comments
Open

BUG: Installation problems with numpy 2.0 #134

ljlamarche opened this issue Jun 24, 2024 · 2 comments
Labels

Comments

@ljlamarche
Copy link
Collaborator

Describe the bug

Recent installations of apexpy in a clean environment appears to succeed, but then fails on import with the traditional fortranapex error.

UserWarning: fortranapex module could not be imported, so apexpy probably won't work.

Based on the traceback (provided below), the problem looks like it may be related to the recent release of numpy 2.0. When installing in a clean environment, pip will automatically try to install the latest version of the numpy as a dependency. If instead I manually install an older version of numpy BEFORE trying to install apexpy, everything works as expected and there are no problems.

pip install numpy==1.26.4
pip install apexpy

There is a numpy migration guide that will likely be useful in adapting apexpy to work with numpy 2.0.

To Reproduce

  1. Create a fresh python environment (python 3.10 used here)
  2. pip install apexpy
  3. In python, import apexpy

Expected behavior

Apexpy should successfully install and be usable from pip.

Traceback

>>> from apexpy import Apex

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<stdin>", line 1, in <module>
  File "/Users/e30737/miniconda3/envs/py310_test/lib/python3.10/site-packages/apexpy/__init__.py", line 5, in <module>
    from apexpy import fortranapex  # noqa F401
AttributeError: _ARRAY_API not found
fortranapex module could not be imported. apexpy probably won't work. Failed with error: numpy.core.multiarray failed to import
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<stdin>", line 1, in <module>
  File "/Users/e30737/miniconda3/envs/py310_test/lib/python3.10/site-packages/apexpy/__init__.py", line 11, in <module>
    from apexpy.apex import Apex, ApexHeightError  # noqa F401
  File "/Users/e30737/miniconda3/envs/py310_test/lib/python3.10/site-packages/apexpy/apex.py", line 13, in <module>
    from apexpy import fortranapex as fa
AttributeError: _ARRAY_API not found
/Users/e30737/miniconda3/envs/py310_test/lib/python3.10/site-packages/apexpy/apex.py:15: UserWarning: fortranapex module could not be imported, so apexpy probably won't work.  Make sure you have a gfortran compiler. Failed with error: numpy.core.multiarray failed to import
  warnings.warn("".join(["fortranapex module could not be imported, so ",

Computer

  • OS: MacOS 14.2.1
  • Python version: 3.10
  • Compiler with version: gfortran 13.1
  • Apexpy version/branch: 2.0.1/main
@ljlamarche ljlamarche added the bug label Jun 24, 2024
@billetd
Copy link

billetd commented Jul 11, 2024

Came here because I also ran into this issue today. Until fixed, it's also possible to just uninstall numpy whilst apexpy is installed, and then reinstall the previous version before 2.0:
pip uninstall numpy
pip install numpy==1.26.4

@aburrell
Copy link
Owner

When fixed, update docs/installation.rst.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants