7

I have ArcGIS 10.2 installed on my machine. When ArcGIS was installed, python 2.7.3(32 bits) was also installed. I need python 2.7.5 64bits for some gdal functions. So I installed python 2.7.5 64bits stand alone. Now there are two python installed with two python shells. One (2.7.3 32bits) can be started from Start---->All Programs--->Python27--->IDLE(GUI). The other(2.7.5 64bits) is from Start---->All Programs--->ArcGIS--->Python27--->IDLE(GUI).

Till now I have my work done in python2.7.5 64bits. Now I want to integrate a model I built in Modelbuilder ArcGIS 10.2. I export this model to python script so that I can see the code behind. I need to import ArcPy module to use ArcPy functions. I tried several ways but no good luck.

Is there any way that I can import arcpy module in this python shell (2.7.5 64bits, not the one installed with ArcGIS)?

Should I install arcpy package first, like what I did for other module? But I didn't see where to download it.


Finally it is resolved. I followed Is 64-bit background geoprocessing native to ArcGIS 10.2? and asked our IT staff to download the package and installed for me. Now my python (came with ArcGIS) is 2.7.5 64bit. I also uninstalled the stand alone python. Re-install all the modules.

8
  • This ESRI post about 64 bit processing in Python may be helpful.blogs.esri.com/esri/arcgis/2012/11/12/…
    – klewis
    Commented Jun 24, 2014 at 23:16
  • Thank you Klewis! I read the news and it seems like it targets ArcGIS 10.1. But I didn't find the same thing for 10.2. If you find it, please let me know!
    – shirleydd
    Commented Jun 24, 2014 at 23:25
  • 2
    This other python module, did you install that yourself or is that the one that came with ArcGis 10.1? Many problems can occur with multiple versions of python on the same computer, they can usually be sorted but there's a bit of work to it. Most likely the install can't find the Esri libs or doesn't have the prerequisites to start them. It is best to use ArcPy with the python that is installed with the current version of ArcGis. Commented Jun 24, 2014 at 23:30
  • Thank you @MichaelMiles-Stimson! I installed another python (2.7.5). I also used gdal module and pyodbc module, which do not come with ArcGIS 10.2. In the beginning, the problem is that python 2.7.5 cannot find arcpy. So I followed some suggestion to put a PTH file in C:\Python27\Lib\site-packages. Its contents are: C:\Program Files (x86)\ArcGIS\Desktop10.2\bin C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts..Then when I tried to import arcpy in python shell, it says: ImportError: DLL load failed: %1 is not a valid Win32 application.
    – shirleydd
    Commented Jun 24, 2014 at 23:37
  • 2
    That error says I can't find the file that it's asking for but that could just as easily mean that's a 64 bit lib in a 32 bit python. It is best to use the python that was installed with ArcGis if you want to use ArcPy; if you want to use GDAL too then adjust that pythons' paths to suit GDAL. It's easier to adjust to suit GDAL than Esri! Commented Jun 24, 2014 at 23:45

2 Answers 2

8

You'll need to get a 64 bit ArcGIS installation of some sort to get arcpy to work correctly in a 64 bit installation. The most expedient thing would be to install 64 bit background geoprocessing for your current install of ArcGIS. That will install a 64 bit version of all the necessary Python libraries needed to use arcpy.

7
  • Thank you Jason! I guess esri is going to release ArcGIS Pro, which is a 64bit one, soon? I tried your method. But I only found 64 bit background geoprocessing for 10.1, not 10.2. I am wondering whether there is one for 10.2 since I tried to install the one for 10.1 and it is failed.
    – shirleydd
    Commented Jun 24, 2014 at 23:31
  • 2
    There should be a 64 bit background GP somewhere for 10.2, though I wouldn't know where to look either. Pro App is going to be 64 bit, yes, but it's also going to be based on Python 3.4 instead of 2.7 and some APIs (namely arcpy.mapping) are being totally overhauled so it won't be a clean 1:1 upgrade path. Commented Jun 24, 2014 at 23:34
  • Thanks Jason. Yap, I guess so, but I didn't find it either...I think I will keep look for and trying some ways I found. If none of them works, I have to try to use python2.7.3 which came with ArcGIS. That is 32bit right?
    – shirleydd
    Commented Jun 24, 2014 at 23:42
  • Yes, the Python that comes with ArcGIS for Desktop is 32 bit Commented Jun 24, 2014 at 23:43
  • 2
    This may help you locate the 64bit install for 10.2: gis.stackexchange.com/questions/80459/…
    – PolyGeo
    Commented Jun 25, 2014 at 0:06
1

When calling a script from the command line, this can be resolved by explicitly calling the correct version of Python and then passing in the path to the script followed by any arguments to the script

enter image description here

This fixed my problem.

Easier than working with environment path, you can just call the python path (32bit) in c\python27\arcgis folder in command line to pass the path to .py file.

1
  • 1
    Links can break with time. Please, include the relevant parts of it, in the answer (use the edit button beneath your answer). Thanks and welcome to GIS SE. Commented Apr 6, 2016 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.