繁体   English   中英

MAC Python 3.8 导入panda模块时出现IntelliJ错误

[英]MAC Python 3.8 IntelliJ error while importing panda module

在我的 Apple M1 芯片机上,试图在 IntelliJ IDEA 中导入 panda 模块。 在运行这个程序时,它给出了以下错误。

如果我在命令行中运行相同的程序,它就可以工作。 在IDE运行时遇到这个问题。

对解决此错误消息有帮助吗?

代码

import os
import pandas as pd

从此 output 中删除我的主目录:

错误

Traceback (most recent call last):
  File "panda-test01.py", line 9, in <module>
    import pandas as pd
  File "Library/Python/3.8/lib/python/site-packages/pandas/__init__.py", line 16, in <module>
    raise ImportError(
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.8 from "/Library/Developer/CommandLineTools/usr/bin/python3"
  * The NumPy version is: "1.22.3"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen(Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 0x0002): tried: 'Library/Python/3.8/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

谢谢

来自您的错误消息:(mach-o 文件,但它是一个不兼容的架构(有“arm64”,需要“x86_64”))

这有点模棱两可,因为它可以被任何一种方式解释,但我认为这意味着 IntelliJ 在 X86 模式下使用 Rosetta2 运行,而 python PATH 的 numpy/pandas 安装是你的 arm 版本。 (备选方案与此相反,但这种方式更有可能)。

为了运行你的程序,你需要创建一个 python 环境,它使用 Rosetta2 并安装 X86 二进制文件而不是 arm。我在这里写了如何做到这一点作为我自己的参考。 然后 IntelliJ 应该在某处有一个设置来指定用于执行和调试的 python 环境,您应该将该环境/路径设置为新的 X86 环境。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM