Unable to create Virtualenv using virtualenv-2.7 - python

I have 2 versions of Python in Centos Linx- Python2.6 & Python2.7..Im trying to create a virtualenv using my virtualenv-2.7 and get the following error.
[root#linuxhost PythonProjects]# virtualenv-2.7 --distribute ENV
New python executable in ENV/bin/python2.7
Not overwriting existing python script ENV/bin/python (you must use ENV/bin/python2.7)
Installing setuptools, pip...
Complete output from command /home/prem/PythonProjects/ENV/bin/python2.7 -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.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 "/usr/local/lib/python2.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 "/usr/local/lib/python2.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 "/usr/local/lib/python2.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 "/usr/local/lib/python2.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 "/usr/local/lib/python2.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 "/usr/local/lib/python2.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 "/usr/local/lib/python2.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 "/usr/local/lib/python2.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: /usr/local/lib/python2.7/site-packages/virtualenv-1.11-py2.7.egg/EGG-INFO/PKG-INFO is not a subpath of /usr/local/lib/python2.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-2.7", line 9, in <module>
load_entry_point('virtualenv==1.11', 'console_scripts', 'virtualenv-2.7')()
File "/usr/local/lib/python2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 820, in main
symlink=options.symlink)
File "/usr/local/lib/python2.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 "/usr/local/lib/python2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 956, in install_wheel
'PIP_NO_INDEX': '1'
File "/usr/local/lib/python2.7/site-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 898, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/prem/PythonProjects/ENV/bin/python2.7 -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip failed with error code 1

I've had this problem once.
I think maybe it is the pip problem.
So I follow the below link's instructions and install pip for python 2.7.
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo /usr/local/bin/python2.7 ez_setup.py
sudo /usr/local/bin/easy_install-2.7 pip
Then
virtualenv -p /usr/local/bin/python2.7 env
worked.
please take a look into the link below.
https://github.com/0xdata/h2o/wiki/Installing-python-2.7-on-centos-6.3.-Follow-this-sequence-exactly-for-centos-machine-only#installing-and-configuring-distribute-setuptools
fyi

Related

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

How can I create a virtualenv in python?

I have 2 versions of python - osx's version and the anaconda version.
I am trying to use my system python and the virtualenv pip package to do this.
first:
Alexs-MacBook-Pro-6:kartograph-test alex$ which python
/usr/local/bin/python
Alexs-MacBook-Pro-6:kartograph-test alex$ which virtualenv
/usr/local/bin/virtualenv
Alexs-MacBook-Pro-6:kartograph-test alex$ which pip
/usr/local/bin/pip
So these guys are all in the same place. Additionally, here is my PATH
Alexs-MacBook-Pro-6:kartograph-test alex$ echo $PATH
/usr/local/bin:/Users/alex/anaconda2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Now I here is the command I run as well as the output:
Alexs-MacBook-Pro-6:kartograph-test alex$ virtualenv -p /usr/bin/python2.7 venv
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in venv/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/alex/kartograph-test/venv/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 "/Library/Python/2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/alex/kartograph-test/venv/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /Users/alex/kartograph-test/venv/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv.py", line 2363, in <module>
main()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Library/Python/2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/alex/kartograph-test/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
now when I try and create it with /usr/local/bin/python2.7 I get
Alexs-MacBook-Pro-6:kartograph-test alex$ virtualenv -p /usr/local/bin/python2.7 venv
Running virtualenv with interpreter /usr/local/bin/python2.7
Overwriting venv/lib/python2.7/orig-prefix.txt with new content
New python executable in venv/bin/python2.7
Not overwriting existing python script venv/bin/python (you must use venv/bin/python2.7)
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv.py", line 2363, in <module>
main()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 994, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1427, in install_python
os.symlink(py_executable_base, full_pth)
OSError: [Errno 17] File exists
Im not sure which one I should be using or which error is more avoidable. All I want is 1 virtualenv that uses python 2.7. Can anyone help me make one?
rm -rf venv
virtualenv venv
You broke the venv folder during your first try, and the second try cannot create because the folder exists.
Since the proper python version is in the path, you don't need to specify it.

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

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

Error when ex mkvirtualenv in Mountain Lion

I have Mountain Lion and I installed virtualenv using this method:
sudo easy_install pip
sudo pip install virtualenv virtualenvwrapper
echo "export WORKON_HOME=$HOME/Envs" >> $BASH_CONFIG_FILE
echo "source /usr/local/bin/virtualenvwrapper.sh" >> $BASH_CONFIG_FILE
source ~/.bashrc
There is a problem when I try to create the virtualenv with this command:
mkvirtualenv test
I receive this error:
New python executable in test/bin/python
Installing setuptools...........
Complete output from command /Users/marco/Envs/test/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" /Library/Python/2.7/...ols-0.6c11-py2.7.egg:
Traceback (most recent call last):
File "<string>", line 279, in <module>
File "<string>", line 207, in main
File "/Library/Python/2.7/site-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/__init__.py", line 2, in <module>
File "/Library/Python/2.7/site-packages/virtualenv_support/setuptools-0.6c11-py2.7.egg/setuptools/extension.py", line 1, in <module>
File "/Users/marco/Envs/test/lib/python2.7/distutils/__init__.py", line 16, in <module>
exec(open(os.path.join(distutils_path, '__init__.py')).read())
IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/__init__.py'
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.7.2', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 942, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1052, in create_environment
search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 598, in install_setuptools
search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 570, in _install_req
cwd=cwd)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 1020, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/marco/Envs/test/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" /Library/Python/2.7/...ols-0.6c11-py2.7.egg failed with error code 1
Can you help me?
Thanks!
Mark
You don't have setuptools installed,
Install it from here
if you upgraded from lion to mountain lion, the python install is broken due to some changes in the file-system, ideally you should install command line tools from xcode, then python from python website, then setuptools from python website and then pip via easy_install, everything will work afterwards.
Problem solved:
Xcode 4 doesn't automatically install the command line tools.
Basically, install Xcode, go into Preferences and then Downloads and install "Command Line Tools". It works now.
:)

Categories