有了之前安装matplotlib的经验,下面我尝试了pandas的本地编译安装,并且完美实现了。
首先还是下载源码包,然后解压,执行
/opt/homebrew/bin/python3 -m pip install . --no-binary :all: --no-use-pep517
这里加上的后缀参数指的是禁用二进制文件进行构建,且忽略一切pep517错误,必须加上这个后缀,安装完之后,显示:
Installing collected packages: pytz, pandas
Running setup.py install for pytz ... done
Running setup.py install for pandas ... done
Successfully installed pandas-1.2.3 pytz-2021.1
这里我本以为已经完成了安装,但是在我进入ipython交互环境导入pandas的时候,又出现了错误:
ModuleNotFoundError: No module named 'pandas._libs.interval'
The above exception was the direct cause of the following exception:
ImportError Traceback (most recent call last)
<ipython-input-1-7dd3504c366f> in <module>
----> 1 import pandas as pd
~/Downloads/pandas-1.2.3/pandas/__init__.py in <module>
31 # hack but overkill to use re
32 module = str(e).replace("cannot import name ", "")
---> 33 raise ImportError(
34 f"C extension: {module} not built. If you want to import "
35 "pandas from the source directory, you may need to run "
ImportError: C extension: No module named 'pandas._libs.interval' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --force' to build the C extensions first.
正当我以为不可能编译安装成功的时候,我抱着试一试的心态进行c库的编译(报错信息中提示:you may need to run 'python setup.py build_ext --force' to build the C extensions first
)
/opt/homebrew/bin/python3 setup.py build_ext --force
等了好长时间,显示编译拷贝完成,再次导入pandas,发现已经能正常使用了,超开心!!