pip安装git库出现ModuleNotFoundError: No module named ‘xxx‘

ERROR: Failed to build 'git+https://github.com/xxx,ModuleNotFoundError: No module named 'torch'

这个报错的核心原因是:安装 diff-gaussian-rasterization-w-depth 时,构建环境中没有加载到当前 Conda 环境的 torch 模块(构建阶段的临时环境和运行环境隔离,导致找不到已装的 PyTorch)。以下是分步骤的修复方案,从「快速兜底」到「彻底解决」:

第一步:先确认当前环境已装 PyTorch(排除未安装的情况)

先执行命令验证 torch 是否真的安装在 gaus 环境中:

pip 构建环境的「隔离机制」导致 ------pip 会创建临时环境构建 wheel,该环境默认不继承当前 Conda 环境的 torch,需强制让构建环境加载 torch:

1. 强制构建环境使用当前环境的 torch(关键)

export SETUPTOOLS_USE_DISTUTILS=stdlib

export PIP_NO_BUILD_ISOLATION=0 # 关闭构建隔离,复用当前环境依赖

2. 重新安装 requirements.txt

pip install -r requirements.txt

虚拟环境安装指定版本gcc gxx方法:

conda install -c conda-forge gcc=10 gxx=10

相关推荐
secondyoung18 小时前
Git使用:rebase用法
c语言·经验分享·git·vscode
萧曵 丶19 小时前
CI/CD 流程
git·ci/cd
阿正的梦工坊19 小时前
pip install transformer_engine[pytorch]编译错误解决方法
pytorch·transformer·pip
import_random19 小时前
[git版本控制]git push(详解)
git
于初见月20 小时前
Conda环境中的pip究竟指向哪里?
python·conda·pip
bing_feilong21 小时前
gitee pull 总是需要用户名和密码,该如何设置?
git·gitee
毒鸡蛋21 小时前
GIT报错:Connection to git. closed by remote host.
git
ShallowLin21 小时前
Git简化分支管理(main+develop)
git
犹若故人归1 天前
Github/Gitee和Git实践
git·gitee·github
007php0071 天前
mySQL里有2000w数据,Redis中只存20w的数据,如何保证Redis中的数据都是热点数据
数据库·redis·git·mysql·面试·职场和发展·php