Having trouble with virtualenv on Windows 7.
I run:
virtualenv _testenv
It returns:
Traceback (most recent call last):
File "C:Python27Scriptsvirtualenv-script.py", line 9, in <module>
load_entry_point('virtualenv==1.5.2', 'console_scripts', 'virtualenv')()
File "C:Python27libsite-packagesvirtualenv.py", line 558, in main
prompt=options.prompt)
File "C:Python27libsite-packagesvirtualenv.py", line 647, in create_environment
site_packages=site_packages, clear=clear))
File "C:Python27libsite-packagesvirtualenv.py", line 771, in install_python
copy_required_modules(home_dir)
File "C:Python27libsite-packagesvirtualenv.py", line 725, in copy_required_modules
dst_filename = change_prefix(filename, dst_prefix)
File "C:Python27libsite-packagesvirtualenv.py", line 710, in change_prefix
(filename, prefixes)
AssertionError: Filename c:Python27Libos.py does not start with any of these prefixes: ['C:\Python27']
I have the following environment variables:
PYTHONHOME=C:Python27
PYTHONPATH=c:Python27;c:Python27Lib
PYTHONSTARTUP=C:UsersLarry.pythonrc
PATH=%PYTHONHOME%;%PYTHONHOME%Scripts;etc
Installed ActiveState Python:
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32
I updated the PYTHONPATH=C:Python27;C:Python27Lib
Still looking for a solution, I found and removed AppData/Python*. Reinstalled Python and now have a different error:
C:xbz>virtualenv _t
PYTHONHOME is set. You *must* activate the virtualenv before using it
Overwriting _tLibsite.py with new content
New python executable in _tScriptspython2.7.exe
Not overwriting existing python script _tScriptspython.exe (you must use _tScriptspython2.7.exe)
Overwriting _tLibdistutils\__init__.py with new content
Installing setuptools..............
Complete output from command C:xbz\_tScriptspython2.7.exe -c "#!python
"""Bootstrap setuptoo...
" --always-copy -U setuptools:
Traceback (most recent call last):
File "<string>", line 278, in <module>
File "<string>", line 210, in main
File "<string>", line 132, in download_setuptools
File "C:Python27Liburllib2.py", line 94, in <module>
import httplib
File "C:Python27Libhttplib.py", line 71, in <module>
import socket
File "C:Python27Libsocket.py", line 47, in <module>
import _socket
ImportError: No module named _socket
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
File "C:Python27Scriptsvirtualenv-script.py", line 9, in <module>
load_entry_point('virtualenv==1.5.2', 'console_scripts', 'virtualenv')()
File "C:Python27libsite-packagesvirtualenv.py", line 558, in main
prompt=options.prompt)
File "C:Python27libsite-packagesvirtualenv.py", line 654, in create_environment
install_setuptools(py_executable, unzip=unzip_setuptools)
File "C:Python27libsite-packagesvirtualenv.py", line 384, in install_setuptools
_install_req(py_executable, unzip)
File "C:Python27libsite-packagesvirtualenv.py", line 360, in _install_req
cwd=cwd)
File "C:Python27libsite-packagesvirtualenv.py", line 624, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command C:xbz\_tScriptspython2.7.exe -c "#!python
"""Bootstrap setuptoo...
" --always-copy -U setuptools failed with error code 1
I hacked Lib/socket.py and inserted:
import sys
sys.path = ['', 'C:\Python27\lib\site-packages\dotcloud-0.3.1-py2.7.egg', 'C:\Python27\lib\site-packages\dotcloud.cli-0.3.1-py2.7.egg', 'C:\Python27\lib\site-packages\flask-0.7dev_20110622-py2.7.egg', 'C:\Python27\lib\site-packages\werkzeug-0.6.2-py2.7.egg', 'C:\Python27\lib\site-packages\gunicorn-0.12.2-py2.7.egg', 'C:\Python27\lib\site-packages\wtforms-0.6.3-py2.7.egg', 'C:\Python27\lib\site-packages\repoze.browserid-0.3-py2.7.egg', 'C:\Python27\lib\site-packages\paste-1.7.5.1-py2.7.egg', 'C:\Python27\lib\site-packages\django_pjax-1.0-py2.7.egg', 'C:\Python27\lib\site-packages\paramiko-1.7.7.1-py2.7.egg', 'C:\Python27\lib\site-packages\pycrypto-2.4.1-py2.7-win32.egg', 'C:\Python27', 'C:\Python27\Lib', 'C:\Windows\system32\python27.zip', 'C:\Python27\DLLs', 'C:\Python27\lib\plat-win', 'C:\Python27\lib\lib-tk', 'C:\Python27\lib\site-packages', 'C:\Python27\lib\site-packages\PIL', 'C:\Python27\lib\site-packages\win32', 'C:\Python27\lib\site-packages\win32\lib', 'C:\Python27\lib\site-packages\Pythonwin', 'C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg-info', 'C:\Python27\Scripts', 'C:\Python27\Lib\site-packages\django\bin']
Above
import _socket
The reason was that I was able to import socket from straight python prompt! So stuffed my existing path. I haven't narrowed down exactly which directory made it happy. It at least will reveal to someone else why I am getting the error without it.
Ideas? Suggestions?
Thank you. :)
I hacked Lib/socket.py and inserted:
import sys
sys.path.append('C:\Python27\DLLs')
Above
import _socket
See Question&Answers more detail:
os