导入依赖于numpy的软件包时,导入numpy c extensions失败

发布于 2025-01-30 09:14:57 字数 1508 浏览 3 评论 0原文

当我导入一个取决于numpy(通过熊猫)的软件包时,numpy导入失败了下面的消息。 VS代码不在图片中。

  • 我正在使用M1芯片的MacBook Pro上运行Macos Monterey(12.3.1)。
  • 我从二进制中安装了Python 3.10。
  • 我正在使用Virtualenv和VS代码进行开发,但是当我从终端运行脚本时,故障也会发生。
  • 我构建了一个使用pandas和numpy的软件包(pytable): pytables 。它在我的机器上的项目中运行良好。
  • 但是,当在另一个项目中安装该构建的软件包时 - pip install -i https://test.pypi.org/simple/ pytables - 然后导入它 - 导入pytables as tp - 我在下面获得numpy导入错误。
  • 我将问题隔离到了该导入语句。
  • 我使用pip3在此Virtualenv中安装了Pandas 1.4.1和Numpy 1.22.1,就像我在构建软件包的ENV中所做的那样。
  • 我的系统上也有Python 3.9.1。我需要3.10 pysimplegui。
  • 如果我简单地评论导入,则代码运行正常。

导入错误:

Importerror:无法导入所需的依赖项:numpy:

很重要:请阅读有关如何解决此问题的建议!

导入numpy c extensions失败。此错误可能发生 许多原因,通常是由于您的设置问题或Numpy的原因 安装。

我们已经编译了一些常见原因和故障排除提示:

  https://numpy.org/devdocs/user/troubleshooting-importerror.html
 

请注意并检查以下内容:

  • Python版本是:Python3.10 “/users/alecramsay/.virtualenvs/tstudio/bin/python” * numpy 版本为:“ 1.22.1”

并确保它们是您期望的版本。请小心 研究上面链接的文档以寻求进一步的帮助。

原始错误是: dlopen(/users/alecramsay/.virtualenvs/tstudio/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so,0x0002): '/users/alecramsay/.virtualenvs/tstudio/lib/python3.10/site-packages/numpy/numpy/core/_multiarray_umath.cpython-310-darwin.so'' ', 需要 'x86_64'))

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.html

Please 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'))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文