0

I currently have several Python interpreters installed through ArcGIS, OSGeo and Anaconda.

C:/OSGeo4W64/bin/python.exe
C:/Python27/ArcGIS10.4/python.exe
C:/Users/[UserName]/Anaconda3/python.exe

According to my understanding, each of these correspond to different versions of Python, and also have different libraries.

Consequently, if I want to run a script that uses arcpy, I use the Python interpreter. If I want to access the osgeo library, I use the OSGeo interpreter, and so forth.

This seems inefficient.

For instance, I only have one version of R which I update regularly and use for all my R libraries.

Could I link the Anaconda interpreter to the arcpy and osgeo libraries somehow or is there a reason why they require their own interpreters?

2

Technically you could link one python install to libraries from other installs, but it's quite an ugly thing to do, and prone to errors. And, more than that, you don't have to.

Libraries are located at /lib/site-packages, each python install will have this folder, and in it all its external libraries. You can download any library for any install. What the OSGEO4W, ArcGIS, Anaconda and such do, is install for you a python version and a bunch of libraries that are part of its package. It's just a helping hand, but you could also download a standalone python and keep adding libraries manually. Or add them to existing installs.

For installing Arcpy, check these instructions: https://pythongisandstuff.wordpress.com/2015/09/14/enable-python-installations-that-were-not-installed-by-arcgis-to-access-arcpy-functionality/

Take note that ArcGIS Desktop is a 32-bit software, and will not work with 64-bit python. Also, ArcGIS 10.4 requires python 2.7, no other release will suffice. Your Anaconda python must observe both these restrictions if you wish for the arcpy library to work with it.

Similarly you can do so with all the different libraries that make up the OSGEO suite. They'll also need to observe correct python specifics. As an example, here you can get the GDAL/OGR python bindings: http://www.gisinternals.com/release.php

You'll notice that, aside from matching the python release and version, it must also match the release and version of your GDAL install, and even the version of Visual C++ used to compile your python install.

It is a bit troublesome, but it's doable. The standard repository libraries like numpy can be more easily downloaded with pip.

  • Thanks! Very helpful. It sounds like this might be more trouble than it's worth, then. If I understand what you're saying correctly, I wouldn't be able to use the standard up-to-date version of Python for both ArcGIS and OSGeo. Would it just be simpler to use the interpreters that come installed with them? – Andrew Plowright Jan 17 '18 at 18:17
  • 1
    You can use the most up-to-date python install with ArcGIS, so long as you stick to the 2.7 release cycle (which would be 2.7.14, currently). Same deal with many of the OSGEO suite. However, if you have, say, 64-bit GRASS, you won't be using it with ArcGIS, you'll need to install 32-bit version and use python bindings that point to it. – Roberto Ribeiro Jan 17 '18 at 20:06
  • 1
    As for how to use these different versions, it depends on the person, really. I, personally, like to work with virtual environments (realpython.com/blog/python/python-virtual-environments-a-primer). I set up a different venv for each project I start, and have a couple loose venvs for random testings and such. – Roberto Ribeiro Jan 17 '18 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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