本文介绍了如何解决 M1 Mac 中的导入 pandas 问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我买了 Mac M1,现在正在搭建我的 python 环境.

I bought Mac M1, and now setting up my python environment.

  • 我安装了 Rosetta 2,并将我的终端设置为 Rosetta 2
  • 我用 brew 安装了 pyenv
  • 使用 brew 安装 Sqlite3
  • 使用 pyenv 安装了 python 3.9.4(设置为全局)
  • 使用 brew 安装了 Visual Studio 代码
  • 最后我用pip install pandas"安装了pandas;在我的终端中.

现在我在 VS Code 中打开了一个 jypyter notebook 文件,并尝试将 pandas 导入为 pd,然后它抛出了这个错误:

Now I opened a jypyter notebook file in VS Code, and trying to import pandas as pd,then it threw in this error:

    ---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/var/folders/r5/wq0wq8mx0d56rbrbs38jt94w0000gn/T/ipykernel_10428/1362986570.py in <module>
----> 1 import pandas as pd

~/.pyenv/versions/3.9.4/lib/python3.9/site-packages/pandas/__init__.py in <module>
     20
     21 # numpy compat
---> 22 from pandas.compat import (
     23     np_version_under1p18 as _np_version_under1p18,
     24     is_numpy_dev as _is_numpy_dev,

~/.pyenv/versions/3.9.4/lib/python3.9/site-packages/pandas/compat/__init__.py in <module>
     13
     14 from pandas._typing import F
---> 15 from pandas.compat.numpy import (
     16     is_numpy_dev,
     17     np_array_datetime64_compat,

~/.pyenv/versions/3.9.4/lib/python3.9/site-packages/pandas/compat/numpy/__init__.py in <module>
      5 import numpy as np
      6
----> 7 from pandas.util.version import Version
      8
      9 # numpy versioning

~/.pyenv/versions/3.9.4/lib/python3.9/site-packages/pandas/util/__init__.py in <module>
----> 1 from pandas.util._decorators import (  # noqa
      2     Appender,
      3     Substitution,
      4     cache_readonly,
      5 )

~/.pyenv/versions/3.9.4/lib/python3.9/site-packages/pandas/util/_decorators.py in <module>
     12 import warnings
     13
---> 14 from pandas._libs.properties import cache_readonly  # noqa
     15 from pandas._typing import F
     16

~/.pyenv/versions/3.9.4/lib/python3.9/site-packages/pandas/_libs/__init__.py in <module>
     11
     12
---> 13 from pandas._libs.interval import Interval
     14 from pandas._libs.tslibs import (
     15     NaT,

ImportError: dlopen(/Users/yeung/.pyenv/versions/3.9.4/lib/python3.9/site-packages/pandas/_libs/interval.cpython-39-darwin.so, 2): no suitable image found.  Did find:
    /Users/yeung/.pyenv/versions/3.9.4/lib/python3.9/site-packages/pandas/_libs/interval.cpython-39-darwin.so: mach-o, but wrong architecture
    /Users/yeung/.pyenv/versions/3.9.4/lib/python3.9/site-packages/pandas/_libs/interval.cpython-39-darwin.so: mach-o, but wrong architecture

我现在应该怎么做才能修复它?

What should I do to fix it now?

推荐答案

删除后尝试重新安装 pandas?

Try reinstalling pandas after removing it?

这篇关于如何解决 M1 Mac 中的导入 pandas 问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 13:30
查看更多