Python中安装RXNFP模块失败求助:pip/git clone均遇问题
安装RXNFP模块时tokenizers编译失败的解决方案
问题背景
尝试安装RXNFP模块,遵循官方建议用Conda管理依赖,但无论是pip install rxnfp还是源码克隆安装都失败。已更新pip并通过rustup安装了Rust,仍遇到编译错误。
环境信息
- 操作系统:
macOS 14.4.1 (23E224) - Python版本:
3.6 - Conda版本:
conda 23.7.4
执行的安装步骤
conda create -n rxnfp python=3.6 -y conda activate rxnfp conda install -c rdkit rdkit=2020.03.3 -y conda install -c tmap tmap -y pip install rxnfp
核心报错信息
running build_rust
error: can't find Rust compiler...
ERROR: Failed building wheel for tokenizers
Failed to build tokenizers
ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects
解决方法
1. 让Conda环境识别Rust编译器
安装Rust后,当前终端窗口可能未加载Rust的环境变量。关闭终端重新打开,激活rxnfp环境后再执行安装命令。若仍无效,手动添加Rust路径到当前会话:
export PATH="$HOME/.cargo/bin:$PATH" pip install rxnfp
2. 安装适配Python3.6的tokenizers预编译版本
Python3.6已停止维护,新版本tokenizers无对应预编译包,需指定兼容旧版本:
pip install tokenizers==0.10.3 pip install rxnfp
3. 升级Python版本(推荐方案)
Python3.6对现代包的支持有限,更换为3.8版本重新构建环境:
conda create -n rxnfp_py38 python=3.8 -y conda activate rxnfp_py38 conda install -c rdkit rdkit=2020.03.3 -y conda install -c tmap tmap -y pip install rxnfp
新版本Python可直接使用预编译依赖包,避免编译问题。
4. 源码安装时锁定依赖版本
若选择源码克隆安装,修改项目依赖文件指定兼容的tokenizers版本:
git clone https://github.com/rxn4chemistry/rxnfp.git cd rxnfp echo "tokenizers==0.10.3" >> requirements.txt pip install -e .
内容的提问来源于stack exchange,提问作者Diego De Lozada
相关产品推荐
相关产品推荐

