1

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...

flutefreak7
  • 2,321
  • 5
  • 29
  • 39
  • how do you have `Anaconda 2.0.1 (64-bit)` ? – Padraic Cunningham Aug 11 '14 at 15:04
  • Beats me... here's what I get from `python` and `C:\Anaconda32\python.exe` (lines 3 & 4 removed): `C:\>python Python 2.7.7 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 10:40:02) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> quit() C:\>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 >>>` – flutefreak7 Aug 11 '14 at 15:07
  • I used the `Anaconda-2.0.1-Windows-x86.exe` installer from http://continuum.io/downloads – flutefreak7 Aug 11 '14 at 15:11
  • [Padraic Cunningham](http://stackoverflow.com/users/2141635/padraic-cunningham) is right that it should say 32-bit... something is very wrong... added an edit to post showing example of what it should look like. – flutefreak7 Aug 11 '14 at 15:19
  • If you really want to know how many bits your Python is, look at `8*tuple.__itemsize__`. – asmeurer Aug 11 '14 at 16:01
  • so you have both installed? – Padraic Cunningham Aug 11 '14 at 16:47
  • Yes, my goal is to be able to work with both, especially to create 32 bit or 64 bit frozen executables with py2exe. – flutefreak7 Aug 11 '14 at 17:12
  • I wiped both python installations from my system and installed Anaconda 32-bit Python 2.7 to C:\Anaconda32. Any calls to python resulted in a 'no module named site' error. This lead me to [here](http://stackoverflow.com/questions/5599872/python-windows-importerror-no-module-named-site) and the solution: an old PYTHONHOME environment variable was pointing to C:\Anaconda (which is now empty). I removed the environment variable completely and now my Python is working. Removing PYTHONHOME might could have solved my original problem. I'll update with an answer if I get 32+64 working. – flutefreak7 Aug 12 '14 at 16:01

1 Answers1

2

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.

flutefreak7
  • 2,321
  • 5
  • 29
  • 39
  • I have the same problem, how were you able to remove the "PYTHONHOME" and "PYTHONPATH" variables? (I am doing this because I am trying to install the boost/python libraries which won't link with the 64-bit version of Python). – Bazman Feb 23 '15 at 17:43
  • Is it possible to open each version separately from Powershell? Currently I just type python into powershell and anaconda 1.8 64 bit with python 2.7.5 starts. – Bazman Feb 23 '15 at 17:52
  • 1
    On Windows 7, I do Control Panel > System > Advanced System Settings (requires UAC) > Advanced Tab > Environment Variables, then find the variable and click the delete button. When I need to run `pip` or `conda` for a specific version I use `cd` to navigate to `C:\Anaconda3_64\Scripts` for example, and then `where pip` to verify that the correct path is first in the list, then run the pip or conda command I want. Otherwise PyCharm handles interpreter selection nicely, or I open the appropriate interpreter in the Start Menu (where I recreated some of the overwritten shortcuts per version). – flutefreak7 Feb 23 '15 at 18:49
  • So if I understand I delete the Variables from the Environmental variables list. After that I can just change directory (in Powershell/cmd) to the appropriate version of anaconda and use python.exe to run the version I want. However how will the boost library know which version to use (and where to find the correct version). – Bazman Feb 23 '15 at 19:00