I have a rhel machine with python2.6 installed on it. I've been trying to have an alternate install of python2.7 and set up a virtualenv for using 2.7. I installed python2.7 by building from source as follows:
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
I already had virtualenv installed on the system so I used it to create a venv for 2.7 as follows:
virtualenv -p python2.7 --no-setuptools py27
. py27/bin/activate
Now when I try to install pip inside the venv, it fails like so:
python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 19857, in <module>
main()
File "get-pip.py", line 151, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 81, in bootstrap
import pip
File "/tmp/tmpArPs31/pip.zip/pip/__init__.py", line 15, in <module>
File "/tmp/tmpArPs31/pip.zip/pip/vcs/mercurial.py", line 11, in <module>
File "/tmp/tmpArPs31/pip.zip/pip/download.py", line 29, in <module>
File "/tmp/tmpArPs31/pip.zip/pip/_vendor/__init__.py", line 81, in load_module
ImportError: No module named 'pip._vendor.requests'
Can't figure out what's going wrong here. Please help.
I've installed python 2.7.8.
EDIT: I initially tried creating virtualenv without --no-setuptools option but that gave me the same error:
virtualenv -p python2.7 py27_with_pip
Running virtualenv with interpreter /usr/local/bin/python2.7
New python executable in py27_with_pip/bin/python2.7
Also creating executable in py27_with_pip/bin/python
Installing setuptools, pip...
Complete output from command /data1/home/sagraw1/...th_pip/bin/python2.7 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/virtualenv-12.0-py2.6.egg/virtualenv_support/pip-6.0- py2.py3-none-any.whl/pip/__init__.py", line 15, in <module>
File "/usr/lib/python2.6/site-packages/virtualenv-12.0-py2.6.egg/virtualenv_support/pip-6.0-py2.py3-none-any.whl/pip/vcs/mercurial.py", line 11, in <module>
File "/usr/lib/python2.6/site-packages/virtualenv-12.0-py2.6.egg/virtualenv_support/pip-6.0-py2.py3-none-any.whl/pip/download.py", line 29, in <module>
File "/usr/lib/python2.6/site-packages/virtualenv-12.0-py2.6.egg/virtualenv_support/pip-6.0-py2.py3-none-any.whl/pip/_vendor/__init__.py", line 81, in load_module
ImportError: No module named 'pip._vendor.requests'
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/virtualenv-12.0-py2.6.egg/virtualenv.py", line 2363, in <module>
main()
File "/usr/lib/python2.6/site-packages/virtualenv-12.0-py2.6.egg/virtualenv.py", line 848, in main
symlink=options.symlink)
File "/usr/lib/python2.6/site-packages/virtualenv-12.0-py2.6.egg/virtualenv.py", line 1016, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/usr/lib/python2.6/site-packages/virtualenv-12.0-py2.6.egg/virtualenv.py", line 984, in install_wheel
'PIP_NO_INDEX': '1'
File "/usr/lib/python2.6/site-packages/virtualenv-12.0-py2.6.egg/virtualenv.py", line 926, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /data1/home/sagraw1/...th_pip/bin/python2.7 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1
I tried installing pip with python2.7 directly but even that doesn't work:
python2.7 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 19857, in <module>
main()
File "get-pip.py", line 151, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 81, in bootstrap
import pip
File "/tmp/tmpPSVEkk/pip.zip/pip/__init__.py", line 15, in <module>
File "/tmp/tmpPSVEkk/pip.zip/pip/vcs/mercurial.py", line 11, in <module>
File "/tmp/tmpPSVEkk/pip.zip/pip/download.py", line 29, in <module>
File "/tmp/tmpPSVEkk/pip.zip/pip/_vendor/__init__.py", line 81, in load_module
ImportError: No module named 'pip._vendor.requests'
I was in a situation similar to yours, and I eventually found the fix. At least in my case the root problem was that when I compiled python 2.7.8 the build process didn't find the proper OpenSSL libraries (because they were not installed on my system). After make finished running it showed a summary similar to this:
Failed to find the necessary bits to build these modules:
_bsddb _curses _curses_panel
_hashlib _sqlite3 _ssl
This doesn't prevent make install from working, and after that Python works just fine, except that it can't access https URLs and other related functionality. You can tell if this is your case by starting python and then typing
import ssl
If you see an ImportError, then the ssl module is missing. Otherwise, you see no message at all.
I fixed this by installing the OpenSSL libraries by running (as root):
yum install openssl-devel
After this was in place, I rebuilt Python with make (now _ssl was not listed as missing), followed by make install. After this, running get-pip.py worked without a hitch.
Hope this helps!
Related
$ 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!
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.
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
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.
I recently upgraded python from 2.7.6 to 2.7.9 using homebrew. I then tried to 'revirtualise' an existing virtual environment:
sudo virtualenv -p python2.7 existingvenv
But am getting this error:
Traceback (most recent call last):
File "venv.../bin/pip", line 7, in <module>
from pip import main
File "venv.../lib/python2.7/site-packages/pip/__init__.py", line 9, in <module>
from pip.log import logger
File "venv.../lib/python2.7/site-packages/pip/log.py", line 8, in <module>
from pip import backwardcompat
File "venv.../lib/python2.7/site-packages/pip/backwardcompat/__init__.py", line 66, in <module>
from urllib2 import URLError, HTTPError
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 93, in <module>
import hashlib
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 138, in <module>
_hashlib.openssl_md_meth_names)
AttributeError: 'module' object has no attribute 'openssl_md_meth_names'
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 2352, in <module>
main()
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 825, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 993, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 961, in install_wheel
'PIP_NO_INDEX': '1'
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 903, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/robertelliott...hflow-app/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1
I also get the above error when running any pip install x inside the above active virtual environment.
I don't get the error when creating a new virtualenv:
$ virtualenv -p python2.7 newvenv
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
New python executable in newenv/bin/python
Installing setuptools, pip...done.
Is there an old symlink or something inside the existing virtualenv causing the issue and how can I resolve this?
This is because of a new feature in Python, which wheel 0.24 is not compatible with. You'll find a folder called virtualenv_support containing base install files for setuptools, pip, and wheel under your Python 2.7 system install. There are a few solutions. The easiest is to just remove wheel-0.24* from the virtualenv_support folder. If you want to go a step farther, you could download version 0.26 of the wheel .whl file and replace it.
did you try:
sudo virtualenv --clear -p python2.7 existingvenv
?