该问题是由于安装pipenv时覆盖了系统管理的pip版本造成的。您执行了正确的第一步,使系统管理的点恢复正常:
sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
完成此操作后,需要注意的是,由于 pip 冲突,pipenv 可能无法在全局级别安装。您可以在用户级别安装 pipelinev:
pip install --user pipenv
这应该在 /home/username/.local 中的用户级别安装 pipelinev,这样它就不会与 pip 的全局版本冲突。就我而言,运行“--user”开关后仍然不起作用,因此我再次运行更长的“修复我搞砸的”命令来准备环境:
sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
然后执行以下操作:
mkdir /home/username/.local
...如果它还不存在
export PYTHONUSERBASE=/home/username/.local
确保导出成功(在此过程中咬了我一次):
echo $PYTHONUSERBASE
然后,我运行了pip install --user pipenv
一切都很好。然后我可以从 CLI 运行 pipelinev,它不会覆盖全局/系统管理的 pip 模块。当然,这是特定于用户的,因此您需要确保在以您希望使用 Pipenv 的用户身份工作时以这种方式安装 Pipenv。
参考:
https://pipenv.readthedocs.io/en/latest/diagnose/#no-module-named-module-name https://pipenv.readthedocs.io/en/latest/diagnose/#no-module-named-module-name
https://pipenv.readthedocs.io/en/latest/install/#pragmatic-installation-of-pipenv https://pipenv.readthedocs.io/en/latest/install/#pragmatic-installation-of-pipenv
https://pip.pypa.io/en/stable/user_guide/#user-installs https://pip.pypa.io/en/stable/user_guide/#user-installs