【发布时间】:2021-11-01 08:31:32
【问题描述】:
尽管正确安装了所需的开发库和 venv 库,但我还是收到了这些连续错误。
这是终端中的连续输出。
~/Desktop/virtualenvs$ python3.8 -m venv newpy38
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt-get install python3-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
Failing command: ['/home/dji/Desktop/virtualenvs/newpy38/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']
当我运行 sudo apt-get 来确定我已经安装了 venv 库时
~/Desktop/virtualenvs$ sudo apt-get install python3-venv
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-venv is already the newest version (3.6.7-1~18.04).
0 upgraded, 0 newly installed, 0 to remove and 458 not upgraded.
当我再次运行 sudo apt-get 来确定时,我已经安装了 venv 库
~/Desktop/virtualenvs$ sudo apt-get install python3.8-venv
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3.8-venv is already the newest version (3.8.0-3~18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 458 not upgraded.
我也尝试了以下链接,但无济于事:
- python3.8-venv not working with python3.8 -m venv env
- pyvenv not working because ensurepip is not available
- 我还通过使用“sudo dpkg-reconfigure locales”的语言环境进行了重置,如https://askubuntu.com/questions/33025/locale-settings-are-not-right-how-can-i-reset-them。但这可能无关紧要。
=== 更新 === 不知何故,卸载并重新安装 python 解决了这个 venv 问题。我也不知道为什么。
【问题讨论】:
-
基于
/home/dji/Desktop/virtualenvs/newpy38/bin/python3.8,您已经启用了 virtualenv。 -
是的,目录已创建。但我无法执行源/bin 激活。它说找不到文件。另外,感谢您帮助我重新格式化。我尝试使用引号,但没有用。
-
当你已经有一个 venv 时,你不需要激活它。
-
嗨,是的,我明白这一点。但是没有一个活跃的venv。我将我的 venv 命名为“newpy38”,并且在终端行的开头没有 (newpy38)。最后,似乎重新安装 python 解决了整个问题。
-
您好,实际上我最终重新刷新了我的嵌入式计算机的操作系统,一切正常。当然,虽然这是一个全面的解决方案,但我相信我已经破坏了我的 python 安装,因为 sudo apt-get autoremove 使用不当。不过,感谢您花时间在这上面!
标签: python python-3.x linux ubuntu