Problem importing arcpy in ArcMap console -- 64 bit DLL conflict

13143
23
Jump to solution
03-05-2013 12:35 AM
JohnBurkhart1
New Contributor II
Hello,

Working on Windows 7 with ArcGIS 10.1 using the 64 bit geoprocessing python... I have been having problems with using python **inside** ArcMap. Outside of ArcMap, I can run the ArcGISx6410.1/python.exe without problems. Here is my WORKING case:

arcpython.bat which will launch 64 bit python and use 64 bit libraries/modules and wraps everything in Ipython.
@echo off set path=C:\Python27\ArcGISx6410.1;%path% set PYTHONPATH=C:\Python27\ArcGISx6410.1\Lib\site-packages\;C:\Python27\Lib\;C:\Python27\Lib\site-packages\;%pythonpath% C:\Python27\ArcGISx6410.1\python.exe -c "import sys; from IPython.frontend.terminal.ipapp import launch_new_instance; sys.exit(launch_new_instance())" %* exit /B %ERRORLEVEL%


With this, I get an Ipython window and all arcpy functionality with no errors.

However, when I launch the python console inside of ArcMap I get a traceback with the following ultimate error:
  File "C:\Python27\Lib\site-packages\numpy\lib\type_check.py", line 8, in <module>     import numpy.core.numeric as _nx   File "C:\Python27\Lib\site-packages\numpy\core\__init__.py", line 5, in <module>     import multiarray ImportError: DLL load failed: %1 is not a valid Win32 application. >>> 


So clearly, it's a problem with the 64 bit imports.

I have my PYTHONPATH set to point to my 64 bit libraries, and I've defined a pythonExePath to point to the ArcGISx6410.1/python.exe.

I'm stumped, because I don't understand how to control which python executable is called from **WITHIN** Arcmap. Output from the console only provides this:

>>> import sys >>> sys.executable  'C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\bin\\ArcMap.exe' >>> 


Please advise on how to instruct the console to use the ArcGISx6410.1/python.exe because that seems to be the problem...

Thanks,
john
Tags (2)
0 Kudos
23 Replies
curtvprice
MVP Esteemed Contributor
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
ImportError: Module use of python26.dll conflicts with this version of Python.

I've looked for the python27.dll But i CAN'T find it!


This is because you are running the wrong version of Python. ArcGIS 10.0 uses 2.6.x, ArcGIS 10.1/10.2 uses 2.7.x. (10.2 isn't out yet, but I have it on good authority they are sticking with 2.7 for compatibility for now.)

If you're running ArcGIS 10.0 you should download and install the 32 bit PythonWin for 2.6.
0 Kudos
JavierNavarro
New Contributor
Python paths are a mess. The easiest thing is to have only one version of python in your machine. This isn't possible when you use ArcGIS because it comes with it's own installation of Python. The problem with this is (as you know) that the ArcGIS installation process fails to update the path information properly.

The quickest fix is to remember to specify the right python when you run your scripts through command line (e.g. C:\Python26\ArcGIS10.0\python instead of simply "python" which will take you to your non-Arc python). While not as elegant as fixing the path, this works.
ThomasLaxson
New Contributor III
In my experience, these types of issues appear to be caused by installing PyScripter after installing ArcGIS. The PyScripter installation futzes with the system environment variables and causes some inconsistent behavior, such as sometimes not properly importing arcpy, yielding this error: ImportError: DLL load failed: %1 is not a valid Win32 application. Then again, sometimes it works just fine.

The only thing that worked for me was uninstalling Python and then running the repair installation of ArcGIS.
0 Kudos
by Anonymous User
Not applicable

Had similar problems before. And agree that the easiest way is to re-run the repair installation of ArcGIS.