使用Poetry安装pyarrow等Python模块失败的问题求助
解决方案
1. 修复Poetry运行环境与项目环境不一致问题
你安装Poetry时使用的是系统默认python3(当时大概率是Python3.10),导致Poetry自身运行在3.10环境,和项目指定的3.12环境冲突,引发依赖解析、wheel匹配错误。解决步骤:
- 用Python3.12重新安装Poetry:
curl -sSL https://install.python-poetry.org | python3.12 - - 验证环境一致性:
确认输出中poetry --version poetry env infoPoetry Python对应版本为3.12。
2. 正确安装适配Python3.12的pyarrow
你使用的pyarrow 13.0.0不支持Python3.12(该版本最高兼容至Python3.11),pyarrow从14.0.0版本开始正式支持Python3.12,按以下步骤操作:
- 移除
pyproject.toml中pyarrow的本地wheel配置,改为指定兼容版本:[tool.poetry.dependencies] pyarrow = "^14.0.0" - 确保项目环境为Python3.12,执行安装命令:
此时Poetry会自动下载适配Python3.12的预编译wheel,无需手动编译。poetry add pyarrow
若因特殊架构需编译安装,先补全编译依赖:
sudo apt install python3.12-dev cmake libboost-all-dev
先安装numpy(pyarrow编译依赖)再安装pyarrow:
poetry add numpy poetry add pyarrow
3. 解决pytickersymbols的pyyaml依赖问题
无需手动指定本地wheel,直接在pyproject.toml中明确依赖约束,让Poetry自动处理:
[tool.poetry.dependencies] pytickersymbols = "^1.13.0" pyyaml = ">=6.0,<6.1" # 明确允许6.0版本,满足pytickersymbols的降级需求
执行命令更新锁文件并安装:
poetry lock --no-update poetry install
4. 本地wheel导入错误的原因
你使用的pyarrow-13.0.0-cp310-cp310-*.whl是针对Python3.10编译的,CPython的ABI在3.10到3.12存在兼容性变化,跨版本wheel无法在Python3.12环境正常导入,必须使用对应Python版本的wheel包。
内容的提问来源于stack exchange,提问作者Cyrille
相关产品推荐
相关产品推荐

