在尝试使用Python 3的venv在Ubuntu上创建虚拟环境时,它没有创建激活脚本,并且不断以错误1退出。
根据文档和其他SO帖子(例如https://dev59.com/FmMl5IYBdhLWcg3wwZIq#19848770),我尝试了两种不同的创建方法。
sayth@sayth-TravelMate-5740G:~/scripts$ python3 -m venv test4
Error: Command '['/home/sayth/scripts/test4/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
sayth@sayth-TravelMate-5740G:~/scripts$ source test4/bin/activate
bash: test4/bin/activate: No such file or directory
sayth@sayth-TravelMate-5740G:~/scripts$ ls test4/bin/
python python3
或者sayth@sayth-TravelMate-5740G:~/scripts$ pyvenv-3.4 test5
Error: Command '['/home/sayth/scripts/test5/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
sayth@sayth-TravelMate-5740G:~/scripts$ ls test5/bin/
python python3 python3.4
如何完全创建一个虚拟环境?
如果我按照以下方式操作,仍无法成功,不确定问题出在哪里?
sayth@sayth-TravelMate-5740G:~/scripts$ python3 -Im venv panda3
Error: Command '['/home/sayth/scripts/panda3/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
sayth@sayth-TravelMate-5740G:~/scripts$ python3 -m venv panda4
Error: Command '['/home/sayth/scripts/panda4/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
pyvenv
没有任何问题。 - Eduard Lucapip
没有安装。在使用sudo apt-get install python3-pip
安装后,重新创建虚拟环境,所有预期的文件都在那里了。 - tomocafe