I would like to install 32 bit and 64 bit versions of Python on a Windows machine side-by-side. The default directory is c:\\Python?? for both so I would have to modify one or both of the install directories. I'm curious to see what the "standard" way is to support both versions?
Since my 32-bit Python kept looking in 64-bit directories, I added the following line before importing things,
import sys
sys.path = [r'C:\Python27-32',r'C:\Python27-32\Lib\site-packages'] + sys.path
and that usually worked.
In order to install something that I could not find on Christoph Gohlke's Unnoficial Windows Binaries for Python Extension Packages , I would do he following:
Path
and PYTHONPATH
, C:\\Python27-32;C:\\Python27-32\\Scripts;
shows up before C:\\Python27-64;C:\\Python27-64\\Scripts;
if you're trying to install something that is 32-bit. setup.py
file that you want to install C:\\Python27-32\\python.exe
at the command line import sys, os
sys.path = [r'C:\\Python27-32',r'C:\\Python27-32\\Lib\\site-packages'] + sys.path
os.system( r'C:\\Python27-32\\python.exe setup.py install' )
And that should work, hopefully.
Virtualenv might help here. I personally just use a non-default folder for install, like I have c:\\Python27-64 and c:\\Python32-64 and c:\\python26-32 on my machine.
Then I have bat files in my path like py26.bat and py27.bat and py32.bat, but sometimes it's not pretty. Also, some packages with installers really try to look in the registry for things and I can only get them to install to a single instance.
Obviously, I don't have a perfect solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.