简体   繁体   中英

What's the standard way to handle 32 bit and 64 bit Python installations side-by-side on a Windows machine?

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:

  1. Change the order of my environment variables in my Advanced System Settings, so that the preferred Python version shows up first, eg, make sure that in 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.
  2. Go to the directory containing the setup.py file that you want to install
  3. Start the 32-bit interpreter, ie, run C:\\Python27-32\\python.exe at the command line
  4. Type import sys, os
  5. Type sys.path = [r'C:\\Python27-32',r'C:\\Python27-32\\Lib\\site-packages'] + sys.path
  6. Type 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM