Virtualenv OSError - setuptools pip wheel failed with error code 1

狂风中的少年 提交于 2019-12-18 04:01:52

问题


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.

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?


回答1:


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

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.




回答2:


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. For example if you want to use python 2.7:

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



回答3:


I had this same issue while installing requirements from 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

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)

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.

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




回答4:


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

Info in this link helped me set it up:

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




回答5:


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

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




回答6:


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.




回答7:


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 level as was my Python installation folder (C:/myname/python27) .

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




回答8:


You can get virtualenv to work with conda if you downgrade python to 2.7.9:

$pip install python=2.7.9

You can see the status of this issue on conda's github: https://github.com/conda/conda/issues/1367




回答9:


This will work for virtualenv pip wheel errorcode1 problems and also E unable to locate package problems

apt-get update

apt-get install python-software-properties

apt-get install apt-file

apt-file update

apt-get install software-properties-common

apt-get install <your filename>  



回答10:


Anaconda does seem to sometimes mess up with virtualenv.

Specifying the python system version /usr/bin/python3.5 instead of the conda one solved the issue.




回答11:


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




回答12:


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

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




回答13:


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.




回答14:


Simply you can do this:

Python 2: virtualenv env

Python 3 : python3 -m venv env



来源:https://stackoverflow.com/questions/37637872/virtualenv-oserror-setuptools-pip-wheel-failed-with-error-code-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!