我安装了64位Python(2.7.5)C:\Python27和32位Python C:\Python27_32.
我想使用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
Run Code Online (Sandbox Code Playgroud)
它似乎是在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;
Run Code Online (Sandbox Code Playgroud)
但是,如果我改变每C:\Python27到C:\Python27_32在我的环境变量,那么我不能VIRTUALENV运行(ImportError: No module named pkg_resources).
这是我第一次搞乱virtualenv,所以我肯定我错过了一些基本的东西.如何创建使用32位Python安装的虚拟环境?
为了让您的虚拟环境在您更改路径后运行,您需要将virtualenv安装到32位python中 - 没有什么可以阻止您在每个python中拥有virtualenv的副本.
假设你有python 2.7.c 64位作为你的默认python并且你还安装了python 2.7.x 32位,你无论如何都需要它们 - 同时假设你在Windows上你的两个pythons将安装在某个地方,如:
C:\Python27 和 C:\Python27_64
随着后者走上你的道路.
另外假设你在两者中都安装了pip,无论如何你都需要它用于virtualenv - 将virtualenv安装到你可以运行的32位python:
Path\To\32Bit\pip install virtualenv
Run Code Online (Sandbox Code Playgroud)
要么
set path=C:\Python27;C:\Python27\Scripts;%path%
rem The above should set your 32 bit to be found before your 64 bit
pip install virtualenv
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7494 次 |
| 最近记录: |