【问题标题】:Ensurepip is not found despite successfully installing python3-venv and python3.8-venv尽管成功安装了 python3-venv 和 python3.8-venv,但没有找到 Ensurepip
【发布时间】: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.

我也尝试了以下链接,但无济于事:

  1. python3.8-venv not working with python3.8 -m venv env
  2. pyvenv not working because ensurepip is not available
  3. 我还通过使用“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


【解决方案1】:

原来这是因为 python 安装损坏!由于sudo apt-get updatesudo apt-get autoremove 的使用不当(且不小心),我最终安装了一个损坏的python,无法正确找到其安装的库

我重新安装了python,现在可以了。

额外注意事项: 当我在嵌入式计算机(dji 流形 2g)上使用它时,一些用户可能没有重新安装 python 的简单选项。重新刷新整个固件(预装 python)实际上可能更有帮助,尽管更不方便。

【讨论】:

    猜你喜欢
    • 2022-12-17
    • 2016-09-20
    • 2020-10-27
    • 2021-12-14
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 2020-08-15
    • 1970-01-01
    相关资源
    最近更新 更多