博乐建设工程信息网站,英语教学网站建设意见,品牌设计公司成都,wordpress付费预约插件文章目录 写在前面一、问题描述二、解决方法参考链接 写在前面
自己的测试环境#xff1a; Ubuntu20.04 ROS-Noetic
一、问题描述
自己在通过 pip install 安装module时 #xff08;使用的是 pip install mmcv#xff09;遇到如下问题#xff1a;
ImportError: cannot … 文章目录 写在前面一、问题描述二、解决方法参考链接 写在前面
自己的测试环境 Ubuntu20.04 ROS-Noetic
一、问题描述
自己在通过 pip install 安装module时 使用的是 pip install mmcv遇到如下问题
ImportError: cannot import name packaging from pkg_resources 出现该问题时的终端的全部输出如下
Using cached mmcv-2.2.0.tar.gz (479 kB)Preparing metadata (setup.py) ... errorerror: subprocess-exited-with-error× python setup.py egg_info did not run successfully.│ exit code: 1╰─ [10 lines of output]/tmp/pip-install-qm5a01q8/mmcv_417ac91e439f41a1b12309217221d376/setup.py:5: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.htmlfrom pkg_resources import DistributionNotFound, get_distribution, parse_versionTraceback (most recent call last):File string, line 2, in moduleFile pip-setuptools-caller, line 34, in moduleFile /tmp/pip-install-qm5a01q8/mmcv_417ac91e439f41a1b12309217221d376/setup.py, line 19, in modulefrom torch.utils.cpp_extension import BuildExtensionFile /home/wong/ProgramFiles/anaconda3/envs/pytorch_env/lib/python3.8/site-packages/torch/utils/cpp_extension.py, line 28, in modulefrom pkg_resources import packaging # type: ignore[attr-defined]ImportError: cannot import name packaging from pkg_resources (/home/wong/ProgramFiles/anaconda3/envs/pytorch_env/lib/python3.8/site-packages/pkg_resources/__init__.py)[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed× Encountered error while generating package metadata.
╰─ See above for output.note: This is an issue with the package mentioned above, not pip.
hint: See above for details.报错截图如下
二、解决方法
上述的报错信息表明在安装 mmcv 时出现了 pkg_resources 模块的问题。具体来说似乎是 packaging 模块无法从 pkg_resources 中导入。 解决方法如下 安装packaging 模块 pip install packaging 更新 setuptools 和 pip: pip install --upgrade setuptools pip然后再次运行自己的安装程序即可解决问题。自己是重新运行 pip install mmcv, 就能安装成功了。
参考链接
[1] sider. 2024-11-10.