I'm on Window 7 64-bit and trying to use both Anaconda Python 64-bit and 32-bit distributions on the same system.
I want to be able to build Windows 32-bit executables for distribution (with py2exe), which requires that a 32-bit python interpreter be used. I previously had installed Anaconda Python 64-bit to C:\Anaconda. I have now installed the 32 bit Anaconda Python distribution to C:\Anaconda32. However, when I attempt to run the python interpreter from C:\Anaconda32\python.exe, it is loading the 64-bit environment into my sys.path. The result is that many library calls fail due to a 32-bit process trying to execute 64-bit libraries (I think).
I also tried editing the path inside the cmd.exe session to only include C:\Anaconda32 and C:\Anaconda32\Scripts.
Here's the result:
C:\Anaconda32>echo %path%
C:\Anaconda32;C:\Anaconda32\Scripts
C:\Anaconda32>python.exe
Python 2.7.7 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 10:41:43) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import sys
>>> sys.executable
'C:\\Anaconda32\\python.exe'
>>> sys.path
['', 'C:\\Anaconda32\\python27.zip', 'C:\\Anaconda\\DLLs', 'C:\\Anaconda\\lib', 'C:\\Anaconda\\lib\\plat-win', 'C:\\Anaconda\\lib\\lib-tk', 'C:\\Anaco
nda32', 'C:\\Anaconda', 'C:\\Anaconda\\lib\\site-packages', 'C:\\Anaconda\\lib\\site-packages\\PIL', 'C:\\Anaconda\\lib\\site-packages\\win32', 'C:\\A
naconda\\lib\\site-packages\\win32\\lib', 'C:\\Anaconda\\lib\\site-packages\\Pythonwin', 'C:\\Anaconda\\lib\\site-packages\\runipy-0.1.0-py2.7.egg', '
C:\\Anaconda\\lib\\site-packages\\setuptools-3.6-py2.7.egg']
>>>
The C:\Anaconda\DLLs
, C:\Anaconda\lib
, etc. are the problem. Those should be C:\Anaconda32\*
...
I'd also like to point out that while it says Anaconda 2.0.1 (64-bit)
later on that line it has the compiler info: [MSC v.1500 32 bit (Intel)]
which indicates a 32-bit interpreter is running. The call to sys.executable
also shows that the correct interpreter is running.
This is the result when trying to load most modules.:
>>> import numpy as np
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\numpy\__init__.py", line 168, in <module>
from . import add_newdocs
File "C:\Anaconda\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Anaconda\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda\lib\site-packages\numpy\core\__init__.py", line 6, in <module>
from . import multiarray
ImportError: DLL load failed: %1 is not a valid Win32 application.
>>>
ImportError: DLL load failed: %1 is not a valid Win32 application.
is what happens when attempting to load a 64-bit compiled module from a 32-bit interpreter I believe.
How do I set up the environment for 32-bit so that it will load the 32-bit libraries? I'd prefer for my 64-bit primary installation to remain unaffected (to remain the default when I type python
)
Thanks!
EDIT
This site shows an example of what a 32-bit anaconda 2.0.1 interpreter should look like...
Python 2.7.7 |Anaconda 2.0.1 (32-bit)| (default, Jun 11 2014, 10:41:43) [MSC v.1500 32 bit (Intel)]
So the fact that I have |Anaconda 2.0.1 (64-bit)|
and [MSC v.1500 32 bit (Intel)]
means something is very wrong...
I believe my PYTHONHOME environment variable was set to C:\Anaconda (the 64-bit installation). When I attempted to run C:\Anaconda32\python.exe, it saw the PYTHONHOME variable and attempted to use that directory as the location to load libraries from. This is explained in the Python Docs here.
By removing PYTHONHOME, I am able to run Anaconda 32-bit and 64-bit side by side. Whichever occurs first in my path will be automatically run when typing
python
at the command prompt. When I open either interpreter, I get the correct version and bit information and they load the correct libraries. Also because I selected to set each as the default python during installation, the 32-bit and 64-bit python registry keys were set allowing installers to find the corresponding installation.If you want to use multiple versions of Python side by side, I recommend removing PYTHONHOME and PYTHONPATH if you don't need them to avoid an environment clashing between the different installations. I could be wrong here, but this appeared to solve my problem.
To be completely explicit I installed to C:\Anaconda32 and C:\Anaconda64. That way if I see anything with just C:\Anaconda I know it's incorrect.