'Importing the numpy C-extensions fails when importing a package that depends on numpy
When I import a package I built that depends on numpy (via pandas), the numpy import fails with the message below. VS Code is not in the picture.
- I'm running macOS Monterey (12.3.1) on a MacBook Pro with an M1 chip.
- I installed Python 3.10 from binary.
- I'm using virtualenv and VS Code for development, but the failure also occurs when I run a script from Terminal.
- I built a package (PyTables) that uses pandas and numpy: PyTables. It runs just fine in that project on my machine.
- However, when install that built package in another project --
pip install -i https://test.pypi.org/simple/ pytables-- and then import it --import pytables as tp-- I get the numpy import error below. - I've isolated the problem to just that import statement.
- I installed pandas 1.4.1 and numpy 1.22.1 in this virtualenv using pip3, just as I did in the env where I built the package.
- I also have Python 3.9.1 on my system. I need 3.10 for PySimpleGUI.
- If I simply comment out the import, the code runs fine.
Import error:
ImportError: Unable to import required dependencies: numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.htmlPlease note and check the following:
- The Python version is: Python3.10 from "/Users/alecramsay/.virtualenvs/tstudio/bin/python" * The NumPy version is: "1.22.1"
and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.
Original error was: dlopen(/Users/alecramsay/.virtualenvs/tstudio/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: '/Users/alecramsay/.virtualenvs/tstudio/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
