Error with virtual env on python (MAC) - python

I have a problem working with virtualenv on a MAC...this is what I do:
Tester-MacBook-Pro:myproject tester$ virtualenv foobar
New python executable in /Users/tester/Documents/myproject/foobar/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/tester/...ct/foobar/bin/python - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/Users/tester/anaconda/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/Users/tester/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/tester/Documents/myproject/foobar/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /Users/tester/Documents/myproject/foobar/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /Users/tester/Documents/myproject/foobar/lib/python2.7/lib-dynload/_io.so
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/tester/anaconda/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Users/tester/anaconda/lib/python2.7/site-packages/virtualenv.py", line 713, in main
symlink=options.symlink)
File "/Users/tester/anaconda/lib/python2.7/site-packages/virtualenv.py", line 945, in create_environment
download=download,
File "/Users/tester/anaconda/lib/python2.7/site-packages/virtualenv.py", line 901, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/Users/tester/anaconda/lib/python2.7/site-packages/virtualenv.py", line 797, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/tester/...ct/foobar/bin/python - setuptools pip wheel failed with error code 1

I just encountered the same problem.
It turns out I was using python-2.7.13 and downgrading to 2.7.10 solved that issue.
If you are using Anaconda, you can do that by running:
$ conda install python=2.7.10

Related

pipenv giving errors "ImportError" and "OSError"

$ pipenv --two
Creating a Pipfile for this project...
Creating a virtualenv for this project...
Running virtualenv with interpreter /mnt/ilustre/users/miniconda2/bin/python2
New python executable in /mnt/ilustre/users/.local/share/virtualenvs/bin/python2
Also creating executable in /mnt/ilustre/users/.local/share/virtualenvs/bin/python
Installing setuptools, pip, wheel...
Complete output from command /mnt/ilustre/users/s...s_report/bin/python2 - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/mnt/ilustre/users/miniconda2/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/mnt/ilustre/users/miniconda2/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: /mnt/ilustre/users/.local/share/virtualenvs/lib/python2.7/lib-dynload/_io.so: undefined symbol: PyUnicodeUCS4_Concat
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/mnt/ilustre/users/.local/lib/python2.7/site-packages/virtualenv.py", line 2328, in <module>
main()
File "/mnt/ilustre/users/.local/lib/python2.7/site-packages/virtualenv.py", line 713, in main
symlink=options.symlink)
File "/mnt/ilustre/users/.local/lib/python2.7/site-packages/virtualenv.py", line 945, in create_environment
download=download,
File "/mnt/ilustre/users/.local/lib/python2.7/site-packages/virtualenv.py", line 901, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/mnt/ilustre/users/.local/lib/python2.7/site-packages/virtualenv.py", line 797, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /mnt/ilustre/users/s...s_report/bin/python2 - setuptools pip wheel failed with error code 1
Virtualenv location:
I have solved this question. The reason is the python version used by virtualenv. You can run 'which virtualenv' and then edit the virtualenv file which is a python file. You must change the python interpreter. I change to the 2.7.10 version and virtualenv runs okay. It is 2.7.11 version previously so it reports errors!

Can't create virtual env with pip in Ubuntu - No module named urllib3

I am having the following problem when trying to create a virtual env on Ubuntu:
$ mkvirtualenv test
New python executable in /home/ubuntu/.virtualenvs/test/bin/python
Installing setuptools, pip, wheel...
Complete output from command /home/ubuntu/.virtualenvs/test/bin/python - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/__init__.py", line 16, in <module>
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/vcs/mercurial.py", line 9, in <module>
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/download.py", line 39, in <module>
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/requests/__init__.py", line 58, in <module>
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/requests/utils.py", line 26, in <module>
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/requests/compat.py", line 7, in <module>
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
ImportError: No module named urllib3
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/home/ubuntu/anaconda2/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv.py", line 708, in main
symlink=options.symlink)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv.py", line 941, in create_environment
download=download,
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv.py", line 897, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/virtualenv.py", line 792, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/ubuntu/.virtualenvs/test/bin/python - setuptools pip wheel failed with error code 1
Any ideas on how to fix this? I already try this, worked fine, but using mkvirtualenv still no good.
This seems to be an issue specific to using Anaconda. You can create a virtualenv with the default python:
mkvirtualenv test -p /usr/bin/python

Fail to create the Python virtual environment using the virtualenv command on Mac [duplicate]

I'm trying to follow the directions on the Flask installation website but I encountered an error after I used "sudo easy_install virtualenv" to install virtual environment. Not sure
Opals-MacBook-Pro:~ opalkale$ mkdir myproject
Opals-MacBook-Pro:~ opalkale$ cd myproject
Opals-MacBook-Pro:myproject opalkale$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip...
Complete output from command /Users/opalkale/myproject/venv/bin/python -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/log.py", line 8, in <module>
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 2696, in <module>
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 429, in __init__
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 443, in add_entry
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1722, in find_in_zip
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1298, in has_metadata
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1614, in _has
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1488, in _zipinfo_name
AssertionError: /Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/EGG-INFO/PKG-INFO is not a subpath of /Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.11', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 820, in main
symlink=options.symlink)
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 988, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 956, in install_wheel
'PIP_NO_INDEX': '1'
File "/Library/Python/2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 898, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/opalkale/myproject/venv/bin/python -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip failed with error code 1
This is logged as an issue with the recently released virtualenv 1.11. I had similar issues on Windows with this release.
I believe installing virtualenv 1.10.1 will let you continue working until this issue is addressed.
As timborden said in a comment: version 1.11.2 (of 2014-01-26) fixes this.
"Fixed easy_install installed virtualenvs by updated pip to 1.5.2"
See changelog at: https://pypi.python.org/pypi/virtualenv

Virtualenv failing when creating an enviroment

I don't know the reason, but the function mkvirtualenv is ending in the following error:
LEP:~ lep$ mkvirtualenv myenvironment
New python executable in myenvironment/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/lep/.virtuale...vironment /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/lep/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
File "/Users/lep/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
File "/Users/lep/anaconda/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/Users/lep/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/lep/.virtualenvs/myenvironment/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/lep/.virtualenvs/myenvironment/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/lep/anaconda/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Users/lep/anaconda/lib/python2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Users/lep/anaconda/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Users/lep/anaconda/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Users/lep/anaconda/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/lep/.virtuale...vironment/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
It is was working before and now I am getting this error. Does someone can help me?
Thanks in advance,
Rhenan
Looks like you are using Anaconda Python. You should be using Conda to do this not virtenv.
Try:
LEP:~ lep$ conda create --name myenvironment
Try downgrading to python version 2.7.9
conda install python=2.7.9
Kudos to folks here in the GitHub conda issues section
Addendum: Thanks, Josh Trii Johnston for his comment which basically said the same thing I did... I didn't see that before.

problems with using virtualenv - source command and file not found?

I've been following this tutorial:
https://python-guide.readthedocs.org/en/latest/dev/virtualenvs/
when i type this into terminal:
virtualenv venv
A folder pops up in my directory, as expected, but there is no 'activate' file. only python, python2, and python2.7
I tried this only to get command not found.
AJs-MacBook-Pro-4:petrarch AJ$ source venv/bin/python2.7
-bash: ????: command not found
Sorry! please help this newb.
When I type in virtualenv venv again, i get this:
AJs-MacBook-Pro-4:petrarch AJ$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip...
Complete output from command /Users/AJ/Desktop/st...arch/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
File "//anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/log.py", line 8, in <module>
File "//anaconda/lib/python2.7/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/backwardcompat/__init__.py", line 66, in <module>
File "//anaconda/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "//anaconda/lib/python2.7/httplib.py", line 71, in <module>
import socket
File "//anaconda/lib/python2.7/socket.py", line 47, in <module>
import _socket
ImportError: dlopen(/Users/AJ/Desktop/stanford-ner-2014-06-16/phoenix_pipeline/petrarch/petrarch/venv/lib/python2.7/lib-dynload/_socket.so, 2): Symbol not found: __PyInt_AsInt
Referenced from: /Users/AJ/Desktop/stanford-ner-2014-06-16/phoenix_pipeline/petrarch/petrarch/venv/lib/python2.7/lib-dynload/_socket.so
Expected in: dynamic lookup
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "//anaconda/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.11.6', 'console_scripts', 'virtualenv')()
File "//anaconda/lib/python2.7/site-packages/virtualenv.py", line 824, in main
symlink=options.symlink)
File "//anaconda/lib/python2.7/site-packages/virtualenv.py", line 992, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "//anaconda/lib/python2.7/site-packages/virtualenv.py", line 960, in install_wheel
'PIP_NO_INDEX': '1'
File "//anaconda/lib/python2.7/site-packages/virtualenv.py", line 902, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/AJ/Desktop/st...arch/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1

Categories