Does anyone use both ArcGIS and Python(x,y)?

3416
4
05-30-2013 12:24 PM
JosephChojnacki
New Contributor
Hi community,
I'm trying to get ArcGIS 10.1 and Python(x,y) to peacefully co-exist with a unified installation of Python. Surely someone else is using both these tools... right? Pointers would be much appreciated.

Here's where I've gotten to:
1. VERSION: Since ArcGIS 10.1 uses Python 2.7.2 (which contains NumPy 1.6.1), I went back to the pythonxy install mirrors and found version 2.7.2.0 of Python(x,y) which includes Python 2.7.2 and NumPy 1.6.1.

2. INSTALL: I crossed my fingers and just installed Python(x,y) after copying my original "C:\Python27\ArcGIS10.1\" folder to a safe location. It installs most of the files at "C:\Program Files (x86)\pythonxy\", and the Python files in "C:\Python27\". This is the same folder where my Arc install of Python lives, except Arc placed its version in the sub-folder "\ArcGIS10.1\". So to recap, I now have a "python.exe" and associated files in "C:\Python27\" as well as "C:\Python27\ArcGIS10.1\".

3. NEXT? Both Spyder and ArcGIS 10.1 seem to work so far but I'm guessing this won't last long. Two separate installs on the same machine seems like a bad move in principle. I wonder: Is it possible to change Arc's preferences to point to the version in the parent folder, and condense versions? I've gone through folder by folder and in almost every case the Python(x,y) install includes all the files that ArcGIS 10.1 Python does (and then some). The exception is that the Arc install sometimes includes '.pyc' and '.pyo' versions of some '.py' files. But I'm guessing this isn't a critical difference since both directories contain the actual '.py' file.)

4. Forgot to mention: I added "C:\Python27\ArcGIS10.0\" to the list of system paths, per the instructions in Method 2 at http://forums.arcgis.com/threads/34418-is-it-possible-to-install-other-python-distributions-on-top-o.... I really don't know what this does, just experimenting here... Please advise!

If anyone can offer further guidance on this, it would be much appreciated!!

(PS - I posted the same question at gis.stackexchange.com, so if interested in the answer check there too)
Tags (2)
4 Replies
StacyRendall1
Occasional Contributor III
Hey,

your best bet is probably to point Python(x,y) to the Arc version of Python, if possible, as I don't think you can change which Python Arc is using... I don't know how easy this is to do, or if it is possible at all. I will play around with this and get back to you.

If you can't change the Python used by Python(x,y), you might just have to forgo Python(x,y). You can download and install Spyder (the Python(x,y) editor) to make use of the ArcGIS Python, and all the other things you need that Python(x,y) does you should be able to get and install for your Arc Python; just make sure to get the versions for your Python (2.7.x, 32bit)!

Let me know how you get on!

Stacy
0 Kudos
StacyRendall1
Occasional Contributor III
In reference to your 4th point, adding the path to Python to the system Path means that other programs can call Python without knowing/caring where it actually lives. For example, once it is in the Path you can simply type 'python' into a command prompt from any location on your computer and it will start Python; previously you would have had to provide the full path to python.exe to start it.

In your case I don't think it will change anything...
0 Kudos
StacyRendall1
Occasional Contributor III
Hey,

I did a bit of playing around, and I don't think you can get a unified installation - shared between Python(x,y) and ArcGIS. It is not a huge problem to have multiple Pythons on your system - and heaps of programs actually quietly install their own Pythons (i.e. QGIS, Inkscape...).

However, what you want, presumably, is to have access to the arcpy functionality from Python(x,y). This can be easily done, but has one notable limitation: if you want to develop the program to run within ArcMap/Catalog, as a tool, and it makes use of libraries other than Arcpy and Numpy, you will need to install these to the ArcGIS Python manually. I think all you need to do this is to add the ArcGIS Python to the system path - which you have already done...

To allow Python(x,y) to access arcpy you must first determine if Python(x,y) uses 32 or 64 bit Python - it must match your ArcGIS Python - do this by opening the Python(x,y) Python console and looking at the top, it should say (important bit highlighted): Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32 if 64 bit or Python 2.7.2 (default, Jun 12 2011, 15:0:59) [MSC v.1500 32 bit (Intel)] on win32 if 32 bit.

If Python(x,y) uses 32 bit Python:

  • navigate to the site-packages folder of ArcGIS Python, i.e. C:\Python27\ArcGIS10.1\Lib\site-packages\, and copy the file Desktop10.1.pth, paste it in the site-packages folder of Python(x,y), i.e. C:\Python27\Lib\site-packages\.



If Python(x,y) uses 64 bit Python:

  • follow the instructions here to install ArcGIS 1.01 Service Pack 1 and then the patch for 64 bit background geoprocessing. This will actually install another Python for ArcGIS, sorry!

  • copy DTBGGP64.pth from C:\Python27\ArcGISx6410.1\Lib\site-packages\ to C:\Python27\Lib\site-packages\.



Unfortunately all the Pythons have to stay there for your programs to run - do not try to delete them...

Now you should be good to go. Test it by opening the Python(x,y) console and typing import arcpy.

Let me know if it works!
NickMiller1
New Contributor II

Whilst I followed your steps above and copied the the desktop.pth file created from my ArcGIS install across to my PythonXY install, I found that the install of ArcGIS has mean that the pythonxy console no longer works. Spyder and the idle consul work from the start menu but the shortcut for Python(xy) console doesn't work any more. Any ideas why ArcGIS 10.2 causes this module to fail? Note, I did a vanilla install of both pythonXY (2.7) and ArcGIS 10.2.0.

0 Kudos