栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

【Linux】The virtual environment was not created successfully because ensurepip is not available.

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【Linux】The virtual environment was not created successfully because ensurepip is not available.

问题描述

在 Ubuntu 系统上使用 Python3.8 创建虚拟环境时报错:

$ python -m venv venv
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 install python3.8-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.
解决方案

报错信息中其实已经给了解决方案:

apt install python3.8-venv

当然,如果你不是 root 用户,得加上 sudo:

sudo apt install python3.8-venv

但还是报错:

$ sudo apt-get install python3.8-venv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package python3.8-venv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3.8-venv' has no installation candidate

这个是因为 apt 好久没有更新了,更新一下:

sudo apt-get update

更新之后继续安装:

sudo apt install python3.8-venv

完美解决!

引用参考

https://blog.csdn.net/lan120576664/article/details/50373571

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/977691.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号