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?
If you wish to use multiple versions of Python on a single machine, then pyenv is a commonly used tool to install and switch between versions. This is not to be confused with the previously mentioned depreciated pyvenv script. It does not come bundled with Python and must be installed separately.
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 lineimport 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With