簡體   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