当前位置: 首页>>技术教程>>正文


venv不会创建激活脚本python3

, , , ,

问题描述

尝试在ubuntu上使用venv和python 3创建virtulenv时,不是在创建激活脚本。它最终以错误1退出。

关注SO上的文档和其他文章,例如https://stackoverflow.com/a/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

最佳方案

看起来您在使用Ubuntu 14.04。它与broken pyvenv一起提供。使用Python 3可以轻松创建venv

1.创建无点子的venv

python3 -m venv --without-pip test4

要么

pyvenv-3.4 --without-pip test4

2.在您的环境中获得点子

source test4/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python
deactivate
source test4/bin/activate

要么

pyvenv-3.4 --without-pip myvenv
source ./myvenv/bin/activate
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-3.4.4.tar.gz
tar -vzxf setuptools-3.4.4.tar.gz
cd setuptools-3.4.4
python setup.py install
cd ..
wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz
tar -vzxf pip-1.5.6.tar.gz
cd pip-1.5.6
python setup.py install
cd ..
deactivate
source ./myvenv/bin/activate

资料来源:HackerNewspyvenv-3.4错误:返回非零退出状态1

次佳方案

Anaconda开发了。

如果您正在使用Anaconda或Miniconda,则此解决方案可能会有所帮助:

Conda manages python itself as a package, so that conda update python is possible, in contrast to pip, which only manages Python packages. Conda is available in Anaconda and Miniconda (an easy-to-install download with just Python and conda).

因此,此命令将有助于:

conda update python

对我来说很困扰,但是,请在终端窗口中将手放在键盘上:(单击此处,查看图片)

感谢您的关注,祝您有美好的一天!

第三种方案

命令:

python3 -m virtualenv env

为我工作,而:

python3 -m venv env

才不是。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/8069.html,未经允许,请勿转载。