我在C:\Python27
上安裝了64位Python(2.7.5),在C:\Python27_32
上安裝了32位Python。如何使用virtualenv在Windows中使用32位和64位Python?
我想使用virtualenv設置一個32位的虛擬環境,當我需要使用32位Python時,可以切換到這個環境。一旦設置了該環境,我打算編輯bin\activate
文件以將所有必需的路徑更改爲指向32位目錄。
然而,當我嘗試創建虛擬環境中,我得到以下錯誤:
> virtualenv --python=C:\Python27_32\python.exe foo
Running virtualenv with interpreter C:\Python27_32\python.exe
PYTHONHOME is set. You *must* activate the virtualenv before using it
New python executable in foo\Scripts\python.exe
Installing setuptools...............
Complete output from command C:\Users\<user>\Drop...o\Scripts\python.exe -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" C:\Python27\lib\site...ols-0.6c11-py2.7.egg:
Traceback (most recent call last):
File "<string>", line 278, in <module>
File "<string>", line 238, in main
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py", line 21, in <module>
File "build/bdist.linux-i686/egg/setuptools/package_index.py", line 2, in <module>
File "C:\Python27\Lib\urllib2.py", line 94, in <module>
import httplib
File "C:\Python27\Lib\httplib.py", line 71, in <module>
import socket
File "C:\Python27\Lib\socket.py", line 47, in <module>
import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\virtualenv.py", line 2577, in <module>
main()
File "C:\Python27\lib\site-packages\virtualenv.py", line 979, in main
no_pip=options.no_pip)
File "C:\Python27\lib\site-packages\virtualenv.py", line 1091, in create_environment
search_dirs=search_dirs, never_download=never_download)
File "C:\Python27\lib\site-packages\virtualenv.py", line 611, in install_setuptools
search_dirs=search_dirs, never_download=never_download)
File "C:\Python27\lib\site-packages\virtualenv.py", line 583, in _install_req
cwd=cwd)
File "C:\Python27\lib\site-packages\virtualenv.py", line 1057, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command C:\Users\<user>\Drop...o\Scripts\python.exe -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" C:\Python27\lib\site...ols-0.6c11-py2.7.egg failed with error code 1
這似乎是在做64位的文件夾,而不是在32位夾進口。我不確定是因爲我的環境變量設置的方式,還是因爲我首先在64位Python下安裝了virtualenv。
這些都是我的用戶環境變量:
Path: %PYTHONHOME%;C:\Python27\Scripts
PYTHONHOME: C:\Python27
PYTHONPATH: C:\Python27\Lib;C:\Python27\Lib\lib-tk;C:\Python27\DLLs;
但是,如果我在環境變量改變每C:\Python27
到C:\Python27_32
,那麼我不能VIRTUALENV運行(ImportError: No module named pkg_resources
)。
這是我第一次搞錯了virtualenv,所以我確定我錯過了一些基本的東西。我如何創建一個使用我的32位Python安裝的虛擬環境?
謝謝史蒂夫。這工作。有關於路徑的問題,但會單獨詢問。 – capitalistcuttle
很高興聽到它。 –
你怎麼才能真正安裝虛擬環境到32位的Python? – JPC