Python Virtualenv OSError - setuptools pip wheel 失败,错误代码为 1

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37637872/
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 19:42:39  来源:igfitidea点击:

Virtualenv OSError - setuptools pip wheel failed with error code 1

pythonpipanacondavirtualenvminiconda

提问by Michael Stokes

I get the following error message when trying to set up a virtual environment with virtualenv 15.0.2 but receive OSError setuptools pip wheel failed with error code 1.

尝试使用 virtualenv 15.0.2 设置虚拟环境但收到 OSError setuptools pip wheel failed with error code 1 时,我收到以下错误消息。

New python executable in /Users/nathmorissette/projects/tutorial/venv/bin/python
Installing setuptools, pip, wheel...
  Complete output from command /Users/nathmorissett...rial/venv/bin/python - setuptools pip wheel:
  Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/Users/nathmorissette/miniconda2/lib/python2.7/tempfile.py", line 32, in <module>
    import io as _io
  File "/Users/nathmorissette/miniconda2/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/Users/nathmorissette/projects/tutorial/venv/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /Users/nathmorissette/projects/tutorial/venv/lib/python2.7/lib-dynload/_io.so
  Expected in: dynamic lookup

----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/Users/nathmorissette/miniconda2/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==15.0.2', 'console_scripts', 'virtualenv')()
  File "/Users/nathmorissette/miniconda2/lib/python2.7/site-packages/virtualenv-15.0.2-py2.7.egg/virtualenv.py", line 711, in main
    symlink=options.symlink)
  File "/Users/nathmorissette/miniconda2/lib/python2.7/site-packages/virtualenv-15.0.2-py2.7.egg/virtualenv.py", line 944, in create_environment
    download=download,
  File "/Users/nathmorissette/miniconda2/lib/python2.7/site-packages/virtualenv-15.0.2-py2.7.egg/virtualenv.py", line 900, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/Users/nathmorissette/miniconda2/lib/python2.7/site-packages/virtualenv-15.0.2-py2.7.egg/virtualenv.py", line 795, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/nathmorissett...rial/venv/bin/python - setuptools pip wheel failed with error code 1

Any ideas how to resolve this issue?

任何想法如何解决这个问题?

采纳答案by Michael Stokes

I finally resorted to using conda to set up an environment rather than virtualenv. Apparently virtualenv is not compatible with anaconda.

我最终求助于使用 conda 来设置环境而不是 virtualenv。显然 virtualenv 与 anaconda 不兼容。

Info in this link helped me set it up:

此链接中的信息帮助我进行了设置:

https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/

https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/

回答by FrankZhu

I tried for hours, read lots of posts and finally find a way out.

我尝试了几个小时,阅读了很多帖子,终于找到了出路。

pip uninstall virtualenv conda install virtualenv

pip uninstall virtualenv conda install virtualenv

The reason is the virtualenv installed by pip is not compatible with conda. I don't know more details, but it works for me.

原因是pip安装的virtualenv与conda不兼容。我不知道更多细节,但它对我有用。

回答by MikeL

I got this error while having several python versions installed on my mac. Specifying which python version to be used for your new virtual environment solves the issue.

在我的 mac 上安装了多个 python 版本时出现此错误。指定用于新虚拟环境的 Python 版本可以解决该问题。

By specifying the absolute python path:

通过指定绝对python路径:

virtualenv -p /usr/bin/python2.7 venv

or use your default python link:

或使用您的默认 python 链接:

virtualenv -p python3 venv

回答by Obinna Nnenanya

I had this same issue while installing requirements from requirements.txt.

requirements.txt.

This was what solved the problem for me.

这就是为我解决问题的原因。

  1. pip install --upgrade virtualenv

  2. pip install --upgrade pip

  3. After doing this, if you ever get errors while trying to install a dependency like below

  1. pip install --upgrade virtualenv

  2. pip install --upgrade pip

  3. 执行此操作后,如果您在尝试安装如下依赖项时遇到错误

THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them. pbr==3.1.1 from https://pypi.python.org/packages/0c/5d/b077dbf309993d52c1d71e6bf6fe443a8029ea215135ebbe0b1b10e7aefc/pbr-3.1.1-py2.py3-none-any.whl#md5=75a0f55856bfc9220af0d01244afec43(from -r requirements-test.txt (line 52)):

Expected sha256 60c25b7dfd054ef9bb0ae327af949dd4676aa09ac3a9471cdc871d8a9213f9ac Expected or 05f61c71aaefc02d8e37c0a3eeb9815ff526ea28b3b76324769e6158d7f95be1

Got b11776d9eb0e7b3988bb7bdef4e2d40cf8c168214374d12d1c4495c1346ac10b

ERROR: could not install deps [-rrequirements-test.txt]; v = InvocationError('/app/.tox/py27/bin/pip install -rrequirements-test.txt (see /app/.tox/py27/log/py27-1.log)', 1)

________________________________ summary _______________________________

ERROR: py27: could not install deps [-rrequirements-test.txt]; v = InvocationError('/app/.tox/py27/bin/pip install -rrequirements-test.txt (see /app/.tox/py27/log/py27-1.log)', 1)

这些包与需求文件中的哈希不匹配。如果您更新了软件包版本,请更新哈希值。否则,请仔细检查包装内容;有人可能篡改了它们。PBR == 3.1.1从https://pypi.python.org/packages/0c/5d/b077dbf309993d52c1d71e6bf6fe443a8029ea215135ebbe0b1b10e7aefc/pbr-3.1.1-py2.py3-none-any.whl#md5=75a0f55856bfc9220af0d01244afec43(从-r要求- test.txt(第 52 行)):

预期的 sha256 60c25b7dfd054ef9bb0ae327af949dd4676aa09ac3a9471cdc871d8a9213f9ac 预期的或 05f61c71aaefc02d8e37c0a3eeb96ea678f53eeb96ea678f53eeb9667387355887352585252

得到了 b11776d9eb0e7b3988bb7bdef4e2d40cf8c168214374d12d1c4495c1346ac10b

错误:无法安装 deps [-rrequirements-test.txt];v = InvocationError('/​​app/.tox/py27/bin/pip install -rrequirements-test.txt (见/app/.tox/py27/log/py27-1.log)', 1)

________________________________ 概括 _______________________________

错误:py27:无法安装 deps [-rrequirements-test.txt];v = InvocationError('/​​app/.tox/py27/bin/pip install -rrequirements-test.txt (见/app/.tox/py27/log/py27-1.log)', 1)

Then use pip --no-cache-dir install <package-name>to install the package; where <package-name>is the name of the package you want to install.

然后使用pip --no-cache-dir install <package-name>安装包;<package-name>您要安装的软件包的名称在哪里。

e.g pip --no-cache-dir install pbr

例如 pip --no-cache-dir install pbr

回答by Sergei Loshchilov

Removal of ~/.pydistutils.cfg worked for me.

删除 ~/.pydistutils.cfg 对我有用。

See the following link (last answer):
https://github.com/Homebrew/legacy-homebrew/issues/44836

请参阅以下链接(最后一个答案):https:
//github.com/Homebrew/legacy-homebrew/issues/44836

回答by nim94

Running

跑步

conda install -c anaconda virtualenv=15.1.0 

worked for me.

为我工作。

This is because virtualenv doesnt work with pip while conda exists on your system.

这是因为当您的系统上存在 conda 时,virtualenv 不适用于 pip。

回答by Prometheus

I had the same error even with no anaconda installed. After a few minutes i realized that i was trying to create a virtualenv folder (C:/myname/virtual_folder) at the same directory levelas was my Python installation folder (C:/myname/python27) .

即使没有安装anaconda,我也遇到了同样的错误。几分钟后,我意识到我正在尝试在与Python 安装文件夹 (C:/myname/python27)相同的目录级别创建一个 virtualenv 文件夹 (C:/myname/virtual_folder )。

So I just created a folder and then inside of it (C:/myname/prefolder/..) i run ("virtualenv virtual_folder") with no issues .

所以我只是创建了一个文件夹,然后在它里面 (C:/myname/prefolder/..) 我运行 ("virtualenv virtual_folder") 没有问题。

回答by user10808031

You can save yourself from all this hustle by just downloading latest version of python, install it before you begin openstack or devstack installation. Go to https://www.python.org/downloads/. Installing latest version of python will replace the older version and install all the libraries you need. This saved me four days of trying to install devstack

您只需下载最新版本的 python,在开始安装 openstack 或 devstack 之前安装它,就可以避免所有这些麻烦。转到https://www.python.org/downloads/。安装最新版本的 python 将替换旧版本并安装您需要的所有库。这为我节省了四天尝试安装 devstack 的时间

回答by jlr

For 3.7.3, i did a pip install --upgrade pip (from 18.1 to 19.1)

对于 3.7.3,我做了一个 pip install --upgrade pip(从 18.1 到 19.1)

Then i did the required installation and it worked (for pyinstaller)

然后我做了所需的安装并且它工作了(对于pyinstaller)

回答by Aleksei Chulei

I have the same problem. The reason was with invalid path of python. Fixed it with removing python to 'c:\python37' from appdata. It cuz you have unicode chars in the path name.

我也有同样的问题。原因是python的路径无效。通过从 appdata 中删除 python 到 'c:\python37' 来修复它。因为你的路径名中有 unicode 字符。