我在 VirtualBox 上运行Ubuntu 18.04.5 LTS
。我正在跑步Python 3.6.9
。
尝试创建虚拟环境时,sudo python3 -m venv env
我得到:
admin@admin-VirtualBox:~/Desktop/project$ sudo python3 -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-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/admin/Desktop/project/.venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']
admin@admin-VirtualBox:~/Desktop/project$ python3 --version
Python 3.6.9
admin@admin-VirtualBox:~/Desktop/project$ sudo apt-get install python3.6-venv
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python3.6-venv : Depends: python3.6 (= 3.6.5-3) but 3.6.9-1~18.04ubuntu1.1 is to be installed
E: Unable to correct problems, you have held broken packages.
admin@admin-VirtualBox:~/Desktop/project$
我研究并发现python3
已经venv
预装了。我相信有一些破碎的依赖关系。
我试过了:
admin@admin-VirtualBox:~/Desktop/project$ sudo apt-cache policy python3.6-venv python3.6 python3
python3.6-venv:
Installed: (none)
Candidate: 3.6.5-3
Version table:
3.6.5-3 500
500 http://at.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
python3.6:
Installed: 3.6.9-1~18.04ubuntu1.1
Candidate: 3.6.9-1~18.04ubuntu1.1
Version table:
*** 3.6.9-1~18.04ubuntu1.1 100
100 /var/lib/dpkg/status
3.6.5-3 500
500 http://at.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
python3:
Installed: 3.6.7-1~18.04
Candidate: 3.6.7-1~18.04
Version table:
*** 3.6.7-1~18.04 100
100 /var/lib/dpkg/status
3.6.5-3 500
500 http://at.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
任何建议如何解决这个问题?问题是什么?
感谢您的回复!
跑
software-properties-gtk
第一个选项卡:启用
main
,universe
, 第二个选项卡:启用security
,updates
退出或运行时更新列表
sudo apt update
安装虚拟环境模块(我希望它安装在香草图像上)
sudo apt install python3.6-venv
在不使用的情况下创建虚拟环境
sudo
python3 -m venv .venv
顺便说一句,最好确认哪个是
python3
使用的链接版本