Python pyvenv-3.4 返回非零退出状态 1

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24123150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 04:02:40  来源:igfitidea点击:

pyvenv-3.4 returned non-zero exit status 1

pythonunixpython-3.xvirtualenv

提问by kahonmlg

I'm in Kubuntu 14.04 , I want to create a virtualenv with python3.4. I did with python2.7 before in other folder. But when I try:

我在 Kubuntu 14.04 ,我想用 python3.4 创建一个 virtualenv。我之前在其他文件夹中使用过 python2.7。但是当我尝试:

pyvenv-3.4 venv

I've got:

我有:

Error: Command '['/home/fmr/projects/ave/venv/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

Error: Command '['/home/fmr/projects/ave/venv/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

采纳答案by kahonmlg

I got a solution installing python-virtualenv

我得到了一个安装 python-virtualenv 的解决方案

sudo apt-get install python-virtualenv

and using

并使用

virtualenv --python=/usr/bin/python3.4 venv

回答by H?ken Lid

Pyvenv comes bundled with newer version of python 3 and is supposed to replace virtualenv, so it's not quite the same thing.

Pyvenv 与较新版本的 python 3 捆绑在一起,应该替换 virtualenv,所以它不是完全一样的东西。

There was some problem with the python 3.4 in the first release of Ubuntu 14.04 that caused this error.

在 Ubuntu 14.04 的第一个版本中,python 3.4 有一些问题导致了这个错误。

Upgrading the distro solved this issue for me. I guess it probably works with Kubuntu as well.

升级发行版为我解决了这个问题。我想它可能也适用于 Kubuntu。

sudo do-release-upgrade -d # this takes a while, and involves a reboot as well. 
sudo apt-get install python3.4-venv
pyvenv-3.4 venv

Please read the docs for do-release-upgradebefore running it. Using the -d flag will upgrade to latest devel release, which might include some unstable software.

请在运行之前阅读do-release-upgrade 的文档。使用 -d 标志将升级到最新的开发版本,其中可能包含一些不稳定的软件。

You can't undo do-release-upgrade

您无法撤消 do-release-upgrade

回答by alexanderlukanin13

Same problem on Linux Mint 17 (which is basically Ubuntu 14.04). Installing python3.4-venvdidn't work, so I created virtualenv without pip and then installed pip manually.

Linux Mint 17(基本上是 Ubuntu 14.04)上的同样问题。安装python3.4-venv不起作用,所以我创建了没有 pip 的 virtualenv,然后手动安装了 pip。

  1. Create virtualenv and activate it

    python3 -m venv --without-pip foo
    source foo/bin/activate
    
  2. Download latest versions of setuptoolsand pip:

    wget https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz#md5=6245d6752e2ef803c365f560f7f2f940
    wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz#md5=01026f87978932060cc86c1dc527903e
    
  3. Unpack and install them

    tar xf setuptools-7.0.tar.gz
    tar xf pip-1.5.6.tar.gz
    cd setuptools-7.0
    python setup.py install
    cd ../pip-1.5.6
    python setup.py install
    
  1. 创建 virtualenv 并激活它

    python3 -m venv --without-pip foo
    source foo/bin/activate
    
  2. 下载的最新版本setuptoolspip

    wget https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz#md5=6245d6752e2ef803c365f560f7f2f940
    wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz#md5=01026f87978932060cc86c1dc527903e
    
  3. 解压并安装它们

    tar xf setuptools-7.0.tar.gz
    tar xf pip-1.5.6.tar.gz
    cd setuptools-7.0
    python setup.py install
    cd ../pip-1.5.6
    python setup.py install
    

回答by Matt R

The following worked for me on Ubuntu 13.10:

以下在 Ubuntu 13.10 上对我有用:

pyvenv-3.4 delme --without-pip
source delme/bin/activate
python -Im ensurepip --upgrade --default-pip

回答by Neron.L

I had encountered this issue.

我遇到过这个问题。

To investigate, I executed the same command as pyvenv did, and then I got "locale.Error: unsupported locale setting".

为了进行调查,我执行了与 pyvenv 相同的命令,然后我得到了“locale.Error: unsupported locale setting”。

It finally fixed by configuring "LC_ALL=en_US.UTF-8".

它最终通过配置“LC_ALL=en_US.UTF-8”来修复。

回答by NYCeyes

Here's an approach that is fairly O/S agnostic...

这是一种与 O/S 无关的方法......

Both the pyvenvand pythoncommands themselves include a --without-pipoption that enable you to work around this issue; without resorting to setuptoolor other headaches. Taking note of my inline commentsbelow, here's how to do it, and is very easy to understand:

无论是pyvenvpython命令本身包括一个--without-pip选项,使您能够解决此问题; 无需诉诸setuptool或其他头痛。记下我的inline comments下面,这是如何做到的,并且很容易理解:

user$ pyvenv --without-pip ./pyvenv.d          # Create virtual environment this way;
user$ python -m venv --without-pip ./pyvenv.d  # --OR-- this newer way. Both work.

user$ source ./pyvenv.d/bin/activate  # Now activate this new virtual environment.
(pyvenv.d) user$

# Within it, invoke this well-known script to manually install pip(1) into /pyvenv.d:
(pyvenv.d) user$ curl https://bootstrap.pypa.io/get-pip.py | python

(pyvenv.d) user$ deactivate           # Next, reactivate this virtual environment,
user$ source ./pyvenv.d/bin/activate  # which will now include the pip(1) command.
(pyvenv.d) user$

(pyvenv.d) user$ which pip            # Verify that pip(1) is indeed present.
/path/to/pyvenv.d/bin/pip

(pyvenv.d) user$ pip install --upgrade pip # And finally, upgrade pip(1) itself;
(pyvenv.d) user$                           # although it will likely be the
                                           # latest version. And that's it!

I hope this helps. \(?﹏?)/

我希望这有帮助。\(?﹏?)/

回答by whatintheworld

Quite similar to @prismalytics.io but for those of you who don't like running shell scripts from the web. You can, of course, use --no-index --find-links to point to local copies. Any recent pip wheel file will suffice, this just points to the current version on PyPI.

与@prismalytics.io 非常相似,但对于那些不喜欢从网络运行 shell 脚本的人来说。当然,您可以使用 --no-index --find-links 来指向本地副本。任何最近的 pip 轮文件就足够了,这只是指向 PyPI 上的当前版本。

python3 -m venv --without-pip your_venv
source your_venv/bin/activate
curl 'https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl' > pip.whl
python -m zipfile -e pip.whl $VIRTUAL_ENV/lib/python3*/site-packages
python -m pip install --force-reinstall --upgrade pip

回答by Gregory

You are missing the venv lib for python 3.4, just run:

您缺少 python 3.4 的 venv 库,只需运行:

$ apt-get install python3.4-dev python3.4-venv

And then create your virtualenv

然后创建你的 virtualenv

python3.4 -m venv myVenv

回答by Adarsh V C

This worked for me in python 3.6 and OSX

这在 python 3.6 和 OSX 中对我有用

$ python -m venv --without-pip my_dir
$ source my_dir/bin/activate
$ curl https://bootstrap.pypa.io/get-pip.py | python
$ deactivate
$ source my_dir/bin/activate
(my_dir) user$

回答by freezed

On LMDE2with :

LMDE2上:

  • Python 3.4.2
  • Debian_version : 8.11
  • 蟒蛇 3.4.2
  • Debian_version : 8.11

It was the first time I use python on this machine and I encountered this problem:

第一次在这台机器上使用python,遇到了这个问题:

freezed@machine ~/git/repo % python3 -m venv .venv                            
Error: Command '['/home/freezed/git/repo/.venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
zsh: exit 1     python3 -m venv .venv

I solved this problem with :

我用以下方法解决了这个问题:

sudo apt-get install python3.4-venv

sudo apt-get install python3.4-venv