Select to view content in your preferred language

32-bit and 64-bit Python 2.7 on the same machine

15430
12
Jump to solution
09-13-2012 10:53 AM
ChanningDale
Occasional Contributor
Hello all,

I have installed on a Windows Server 2008 R2 virtual machine ArcGIS for Desktop 10.1 and ArcGIS for Server 10.1.  The desktop install came with the 32-bit version of Python 2.7, and the server install came with the 64-bit version.  I seem to now have a conflict between both versions when I try to work with Python on ArcGIS for Desktop.  I've run into this before with Desktop when I had two different versions of Python on my computer, and the way that I solved it was to keep one and uninstall the other.  In this case, I feel like I wouldn't be able to uninstall either of them, since both pieces of software probably rely on arcpy for certain functions.

Here's the error I get when I try to run my script in the shell and it initially tries to import the arcpy module:

Traceback (most recent call last):
  File "C:\Projects\11047\DATARE~1\Toolbox.pyt", line 1, in <module>
    import arcpy
  File "c:\program files (x86)\arcgis\desktop10.1\ArcPy\arcpy\__init__.py", line 21, in <module>
    from arcpy.geoprocessing import gp
  File "c:\program files (x86)\arcgis\desktop10.1\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from _base import *
  File "c:\program files (x86)\arcgis\desktop10.1\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module>
    import arcgisscripting
ImportError: DLL load failed: %1 is not a valid Win32 application.

Has anyone else come across this problem?  I think I need to change the version that my Python Shell is using, since at the top of the window it says 64 bit (AMD64), but since I'm developing in Desktop, it should probably be 32 bit (Intel 32).  I was able to develop my script, and then today I started to run into this error.

Thanks!
Tags (2)
0 Kudos
12 Replies
DanSpinosa
Deactivated User
We are trying to re-publish a simple geoprocessing service of a script (python) within a toolbox.  The service ran fine in 10.0.  In 10.1 the script runs fine from ArcCatalog, ArcMap, and we can publish the service.  However, we cannot run that 10.1 geoprocessing service (or any other for that matter).  When I check the error log, I am getting the same error as above "... ImportError: DLL load failed: %1 is not a valid Win32 application..."  Any ideas out there?  Our service can be found at:  http://www.innovategeo.com:6080/arcgis/rest/services/Demo/PrintMapBook/GPServer  .  I even went through some demos for publishing services and could not get those to run as well.

Thanks,

-Dan
0 Kudos
ChanningDale
Occasional Contributor
I had one of our developers look at this issue with me.  We went to the location of the IDLE in the 32-bit Python folder and opened the idle.pyw.  When the IDLE window came up, it was still referencing 64-bit Python in the window.  We closed that and opened the idle.py file (so that the command window opened with the IDLE) and the version of Python that was running in the command window was 64-bit, so it was calling pythonw.exe in the C:\Python27\ArcGISx6410.1 folder.  I'm not sure why the 32-bit IDLE was calling the 64-bit executable or where I could've changed that path, but I just ended up uninstalling Desktop and re-installing it (not ideal, I know), and it seemed to fix it because now the 32-bit IDLE references the 32-bit Python executable.

I also deleted my Python toolbox (because after that it was causing my ArcCatalog to crash before it even opened) and created a fresh one.  Luckily, I didn't have much in the toolbox to rewrite and just saved the code in a text file for reference.

Thanks though, Chris, for helping me to dig around a few areas to see what the error could be.  Do you know, though, where I could change the path to the Python executable if this happens again so I don't have to uninstall and re-install Desktop?  I know that's kind of the last ditch fix to correct references.
0 Kudos
ChrisFox3
Frequent Contributor
Ok, I think I got it. It seems to just be a file associations issue. If I install Desktop first then Server, I am finding that launching IDLE from the 32 bit install location, C:\Python27\ArcGIS10.1\Lib\idlelib will load IDLE with the 64 bit version of python. This is because when you install the 64 bit version of python last the file association for .py and .pyw files becomes C:\Python27\ArcGISx6410.1\pythonw.exe. So when you double-click the idle.pyw it is executed using the 64 bit pythonw.exe. So you just need to modify the default file associations of .pyw to point to C:\Python27\ArcGIS10.1\pythonw.exe.

Alternatively you can see the same from command line:

C:\>C:\Python27\ArcGIS10.1\pythonw.exe C:\Python27\ArcGIS10.1\Lib\idlelib\idle.pyw (Opens IDLE with 32 bit version of python)

C:\>C:\Python27\ArcGISx6410.1\pythonw.exe C:\Python27\ArcGIS10.1\Lib\idlelib\idle.pyw (Opens IDLE with 64 bit version of python)
0 Kudos