m1芯片MacBook安装本地编译版pandas库

本文分享了一次成功的Pandas本地编译安装经历。作者详细记录了安装过程中的步骤及遇到的问题,特别是解决了C扩展未编译导致的导入失败问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

写在前面

有了之前安装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,发现已经能正常使用了,超开心!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zorchp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值