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
?
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 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 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!
I need virtualenv for Pyramid on XP.
pip installs fine and so does virtualenv
But when I try to create an instance directory, virtualenv bombs.
I uninstalled and re-installed virtualenv, but I keep getting the same problem.
Any ideas?
C:\>pip --version
pip 1.5.4 from C:\Python334\lib\site-packages (python 3.3)
C:\>virtualenv --version
1.11.4
C:\>virtualenv venv
Using base prefix 'C:\\Python334'
New python executable in venv\Scripts\python.exe
Installing setuptools, pip...
Complete output from command C:\venv\Scripts\python.exe -c "import sys, pip; s
ys...d\"] + sys.argv[1:]))" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'pip'
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "C:\Python334\lib\runpy.py", line 160, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python334\lib\runpy.py", line 73, in _run_code
exec(code, run_globals)
File "C:\Python334\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "C:\Python334\lib\site-packages\virtualenv.py", line 824, in main
symlink=options.symlink)
File "C:\Python334\lib\site-packages\virtualenv.py", line 992, in create_envir
onment
install_wheel(to_install, py_executable, search_dirs)
File "C:\Python334\lib\site-packages\virtualenv.py", line 960, in install_wheel
'PIP_NO_INDEX': '1'
File "C:\Python334\lib\site-packages\virtualenv.py", line 902, in call_subproc
ess
% (cmd_desc, proc.returncode))
OSError: Command C:\venv\Scripts\python.exe -c "import sys, pip; sys...d\"] + sy
s.argv[1:]))" setuptools pip failed with error code 1
C:\>
Python 2.7.9 and later (on the python2 series), and Python 3.4 and later include pip by default [1], so you may have pip already.
(https://pip.pypa.io/en/latest/installing.html)
So, to install pip, securely download get-pip.py. (https://bootstrap.pypa.io/get-pip.py)
Then run the following (which may require administrator access):
python get-pip.py