在我的苹果M1芯片机上,试图导入熊猫模块中的IntelliJ思想。在运行这个程序时,它给出了以下错误。
如果我在命令行中运行相同的程序,它就能工作。在IDE中运行时遇到此问题。
对解决此错误消息有帮助吗?
码
import os
import pandas as pd从此输出中移除我的home dir:
误差
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'))谢谢
发布于 2022-04-13 19:06:19
从您的错误消息:(mach-o文件,但是一个不兼容的体系结构(有‘arm64,需要'x86_64'))
这有点含糊不清,因为它可以用任何一种方式来解释,但我认为这意味着IntelliJ在X86模式下使用Rosetta2运行,而python路径的numpy/大熊猫安装是您的arm版本。(另一种选择是相反的,但这种情况更有可能发生)。
为了运行您的程序,您需要创建一个使用Rosetta2并安装X86二进制文件而不是arm的python环境。我曾经写过如何做这个这里,作为我自己的参考。然后IntelliJ应该有一个设置来指定用于执行和调试的python环境,您应该将该环境/路径设置为新的X86环境。
https://stackoverflow.com/questions/71862433
复制相似问题