Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mac] Trying to create a python virtual environment but getting OSError #788

Closed
jayinai opened this issue Aug 25, 2015 · 22 comments
Closed

Comments

@jayinai
Copy link

jayinai commented Aug 25, 2015

Mac OS X: 10.9.5
pip 7.1.2
virtualenv 13.1.2
Python: Python 2.7.10 :: Anaconda 2.3.0 (x86_64)

Shuais-MacBook-Pro:Google Drive shuaiwang$ virtualenv ENV
New python executable in ENV/bin/python
Installing setuptools, pip, wheel...
Complete output from command "/Users/shuaiwang/Google Drive/ENV/bin/python" -c "import sys, pip; sys...d"] + sys.argv[1:]))" setuptools pip wheel:
Traceback (most recent call last):
File "", line 1, in
File "/Users/shuaiwang/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/init.py", line 13, in
File "/Users/shuaiwang/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/utils/init.py", line 15, in
File "/Users/shuaiwang/anaconda/lib/python2.7/zipfile.py", line 6, in
import io
File "/Users/shuaiwang/anaconda/lib/python2.7/io.py", line 51, in
import _io
ImportError: dlopen(/Users/shuaiwang/Google Drive/ENV/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/shuaiwang/Google Drive/ENV/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup


...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/shuaiwang/anaconda/bin/virtualenv", line 11, in
sys.exit(main())
File "/Users/shuaiwang/anaconda/lib/python2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Users/shuaiwang/anaconda/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Users/shuaiwang/anaconda/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Users/shuaiwang/anaconda/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command "/Users/shuaiwang/Google Drive/ENV/bin/python" -c "import sys, pip; sys...d"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1

@grisaitis
Copy link

I have the exact same error, and I'm using a very similar set up:

  • Mac 10.10.3
  • pip 7.1.2
  • virtualenv 13.0.1
  • Python 2.7.10 :: Anaconda 2.2.0 (x86_64)

@grisaitis
Copy link

This is a possible duplicate of #788

@grisaitis
Copy link

See conda/conda#1367

@Ivoz
Copy link

Ivoz commented Sep 21, 2015

@grisaitis #788 is a duplicate of #788? :D

And yes, at the moment this looks like a conda python issue.

@grisaitis
Copy link

Oops! Sorry, I meant it could be a duplicate of this: #741

@grisaitis
Copy link

And this is "fixed" by downgrading to Python 2.7.9, in case you didn't see in conda/conda#1367

@jayinai jayinai closed this as completed Sep 21, 2015
@jenisys
Copy link

jenisys commented Dec 21, 2015

Actually, it is not fixed (and I am aware that this is probably a condo/virtualenv co-issue).

I have the same problems with Python 2.7.11 and Python 3.5.1 and conda 3.18.9 (and pip 7.1.2).
With Python 3.5.1, virtual environment creation fails with "virtualenv" and "pyvenv" (with a slightly different error).

@Ivoz
Copy link

Ivoz commented Dec 26, 2015

@jenisys please could you paste the actual error?

@jenisys
Copy link

jenisys commented Dec 26, 2015

With a conda environment based on python 2.7.11 and virtualenv 13.0.1, I get the similar error that was described above (but another CPython symbol is missing now);

# -- CASE: Using conda environment "py27" with python 2.7.11
# INSTALLED: virtualenv 13.0.1, pip 7.1.2, wheel 0.26.0
$ virtualenv xxx
New python executable in xxx/bin/python
Installing setuptools, pip, wheel...
  Complete output from command /Users/alice/tmp/venv/xxx/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/alice/conda/envs/py27/lib/python2.7/site-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
  File "/Users/alice/conda/envs/py27/lib/python2.7/site-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
  File "/Users/alice/conda/envs/py27/lib/python2.7/zipfile.py", line 6, in <module>
    import io
  File "/Users/alice/conda/envs/py27/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/Users/alice/tmp/venv/xxx/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /Users/alice/tmp/venv/xxx/lib/python2.7/lib-dynload/_io.so
  Expected in: dynamic lookup

----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/Users/alice/conda/envs/py27/bin/virtualenv", line 6, in <module>
    sys.exit(main())
  File "/Users/alice/conda/envs/py27/lib/python2.7/site-packages/virtualenv.py", line 832, in main
    symlink=options.symlink)
  File "/Users/alice/conda/envs/py27/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/Users/alice/conda/envs/py27/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/Users/alice/conda/envs/py27/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/alice/tmp/venv/xxx/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1

With a conda environment with python 3.5.1, the error looks slightly different:

# -- CASE: Using conda environment "py35" with python 3.5.1
# INSTALLED: virtualenv 13.1.2, pip 7.1.2, wheel 0.26.0
$ virtualenv --verbose xxx2
Using base prefix '/Users/alice/conda/envs/py35'
Creating xxx2/lib/python3.5
Symlinking Python bootstrap modules
  Symlinking xxx2/lib/python3.5/config-3.5m
  Symlinking xxx2/lib/python3.5/lib-dynload
  Symlinking xxx2/lib/python3.5/plat-darwin
  Symlinking xxx2/lib/python3.5/os.py
  ...
  Symlinking xxx2/lib/python3.5/_bootlocale.py
Creating xxx2/lib/python3.5/site-packages
Writing xxx2/lib/python3.5/site.py
Writing xxx2/lib/python3.5/orig-prefix.txt
Writing xxx2/lib/python3.5/no-global-site-packages.txt
Creating parent directories for xxx2/include
Symlinking xxx2/include/python3.5m
Creating xxx2/bin
New python executable in xxx2/bin/python3
Changed mode of xxx2/bin/python3 to 0o755
Also creating executable in xxx2/bin/python
Changed mode of xxx2/bin/python to 0o755
Testing executable with xxx2/bin/python3 -c "import sys;out=sys.stdout;getattr(out, "buffer", out).write(sys.prefix.encode("utf-8"))"
ERROR: The executable xxx2/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/Users/alice/tmp/venv' (should be '/Users/alice/tmp/venv/xxx2')
ERROR: virtualenv is not compatible with this system or executable

When I use pyvenv in the conda environment (as expected with Python 3.x), I get another error related to the missing "ensure pip" module (conda internal problem, I assume).

@lukaemon
Copy link

I have the same issue here, can someone point me the solution for this issue? Since it's closed, must be solved right?

@pfmoore
Copy link
Member

pfmoore commented Jun 11, 2016

@icrtiou It's closed here because it's a conda issue (the issue number is noted above). Doesn't look like it's fixed there yet, but you should review the conda ticket for further information.

@gbrand-salesforce
Copy link

I've ran into a similar error (not using anaconda, installed python using brew install) when I was trying to recreate an env without first deleting the previous env.

after rm -rf of the old env path, the error was solved...

@RubenDuran
Copy link

I had a similar issue with conda and virtualenv. I was able to successfully install and activate an env with the following command:
conda install -c anaconda virtualenv=15.1.0

@ethanjperez
Copy link

Thank you!! That worked for me.

@stevealbertwong
Copy link

my solution is change the default python and pip to /user/bin/python instead of conda version
NOTE: after first conda error virtualenvs folder is already created and stored conda's path and setup, so need to remove that folder first before creating a new virtualenvs folder

rm -rf .virtualenvs/ # remove
source virtualenvwrapper.sh # create bew virtualenvs

@Hu4F00d
Copy link

Hu4F00d commented Nov 22, 2017

The solution proposed by @RubenDuran worked for me.

@mattdodge
Copy link

I wasn't using anaconda and was running into this. Just trying to use pyenv and virtualenvwrapper. I swear this had worked before but I was running this to create a new virtualenv:

pyenv shell 3.6.3
mkvirtualenv my_new_env

That would yield a similar stack trace to those above. To fix it, I installed pyenv-virtualenvwrapper. Then the following is how I got it to work:

pyenv shell 3.6.3
pyenv virtualenvwrapper
mkvirtualenv my_new_env

Not totally sure what happened but it's working and thought I'd share in case anyone else was running into a similar issue.

@apf99
Copy link

apf99 commented Jan 17, 2018

@RubenDuran you are a superstar! You solution worked perfectly for me.

@guidoguidi
Copy link

@RubenDuran thanks a bunch!

@ccerrato147
Copy link

Again @RubenDuran solution worked! Thanks!!!

@ajayshewale
Copy link

Solution to create the virtual environment for your project if you have conda. I had a similar issue, I tried the following command and it worked for me.
Ubuntu 16.04
Python 2.7.14 :: Anaconda, Inc.

conda create -n yourenvname python=x.x anaconda

yourenvname is the name of the virtual environment that you are going to create and use.
pyrhon=x.x: pick the version of python you want to use in this environment

@rbenabbas
Copy link

Hi,
I'm facing to the same situation on centos 7. I fixed the problem with the following lines:

yum install epel-release

yum install python-pip

pip install -U pip

yum -y install python-virtualenv

yum -y install python-virtualenvwrapper

$ export WORKON_HOME=~/.virtualenvs
$ source /usr/bin/virtualenvwrapper.sh
$ mkvirtualenv myapp
$ deactivate
$ workon myapp

@pypa pypa locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests