How to run python with the ArcGIS Pro 1.4 from outside

9643
37
Jump to solution
03-13-2017 04:00 PM
BidhyanandaYadav
New Contributor II

With ArcGIS Desktop, version 10.4 for example, I installed the Anaconda Python and was able to run all the arcpy scripts from outside of the ArcGIS session (for example with Spyder, or Jupyter Notebook) with the following Desktop10.4.pth file created in site-package with following three lines of code

C:\Program Files (x86)\ArcGIS\Desktop10.4\arcpy
C:\Program Files (x86)\ArcGIS\Desktop10.4\bin
C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcToolbox\Scripts

I want to replicate the same behaviour with the new ArcGIS Pro 1.4, but there seems no help on how to do this. I want to know how to do this with the Anaconda Python that is installed by default with ArcGIS Pro 1.4. Do I need to install a separate copy of Anaconda Python?

0 Kudos
37 Replies
DanPatterson_Retired
MVP Emeritus

The top of the link was for 1.4.1, the rest as indicated was for legacy installations.

Just install 1.4.1, use their conda distribution, go to my above link images, set yourself up, install your other packages, create desktop shortcuts and you are ready to go. 

I keep two distributions... one for non-arc* stuff using python 3.6 as the base, then I let Arc* do its thing and install its own conda distribution.... notice the separation.  I also set up spyder to use as my IDE for both arcmap and PRO.  I also set up a Jupyter QT consol and Pythonwin to run in both as well as Pycharm Edu to kick around on those occasions that I want to prepare lecture materials.  The only thing that I don't use anymore is Pyscripter since development seems to be terminated (open the zip... the dates are two years old) and I read that it doesn't play nice anymore with the conda distribution from arc*.  There is no limits to what you can do.  In the pure Anaconda/python3.6 distribution, I am also using Matplotlib 2.0 which will give you a heads up on what you can do should esri update their package list with future releases.

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

I do have Pro 1.4.1 installed.  Not sure why mine isn't working as expected.

edit: I went back to the Pro "Python Package Manager" and "Update PAckages" and noticed it now had an update (wasn't showing yesterday afternoon).  Installing that and trying again.

edit 2:  I think getting that update that was the ticket for me to get the standalone Junyper Notebook to work.  The shortcut with the the (arcgispro-py3) still is not working, but the other shortcut from the separate Anaconda install is opening.       Guess I can cancel the tech support call.

0 Kudos
DanPatterson_Retired
MVP Emeritus

hmmm I am using windows 10, on a local install, not connected to a network at all, but check out your licensing arrangements.  I just find that keeping it untoggled off line easiest and make sure that your licensing portal is specified if it applies to you.  Then you can go to your configure licensing options should all else fail. 

0 Kudos
ShaunWalbridge
Esri Regular Contributor

Bidhyananda,

The issue of the notebook shortcut not working has been added as a bug, BUG-000103143. You should still be able to access the notebooks from the command line, just not from the shortcut directly.

Cheers,
Shaun

BidhyanandaYadav
New Contributor II

Thank you Rebecca Strauch, GISPShaun Walbridge Dan Patterson. I also spent some time figure out the issues based on your comments/suggestions. Here's what I did.

I was able to run Python 3.5 from the default ArcGIS pro installation of Python. While Jupyter notebook and other packages can be directly installed from inside the ArcGIS pro Python panel, installing arcgis python package also helped setup the Jupyter notebook (even though arcgis python and arcpy are separate products). I would definitely recommend arcgis python.

But these are the issues I faced in my work. ArcGIS Pro python is quite restrictive, and I could not install other open source libraries such as GDAL, Geopandas etc. Since, my workflow depend on ArcPy, along with many other open source libraries I am unable to commit fully to ArcGIS Pro Python for all my work.

So I also have Anaconda Python 2.7 for ArcMap 10.5. Definitely, not the solution I was looking for because now I constantly have to switch between the two installations of Python, and this is definitely as hassle (contrary to the spirit of Python).

I would have liked the workflow similar to ArcGIS Desktop which allows you to install you own Python (Anaconda for example) and continue working with ArcPy by just including it in path.

DanPatterson_Retired
MVP Emeritus

hmmmm usually a 'pip' install is offered by a package to allow you to install anything you need.  Some packages don't work well in virtualized environments and/or don't respond well to permanent or temporary additions to the python or system path.  The two packages you cite have alternatives. They may not meet your familiarity level so that is also a workflow concern.  Good luck

PS geos and gdal are available in the anaconda distribution meaning they can be installed in arcpro's version, they just aren't in the package list... which hasn't stopped anyone

0 Kudos
BidhyanandaYadav
New Contributor II

Yeah pip should work, even conda install works. The Python that comes with ArcGIS Pro is not flexible enough to allow user the choice to install other open source packages. Especially, the ones related to open source GIS libraries. My whole interest in starting this question was to find out if anyone has been successful in using the ArcGIS Pro Python for all their workflow.

My intent is to have the latest version of 64-bit Python to accomplish all my work, including the ArcPy functionalities. 

0 Kudos
DanPatterson_Retired
MVP Emeritus

The version of python 3.5.1... is the same python 3.5.1 that everyone uses, there is no difference in python... let us make that absolutely clear... All esri did was produce a 'conda' package of the modules for that particular version of python so that they could ensure that everything would play nice.  For example, the numpy version could have been upgraded, but some packages don't support a higher version, so it wasn't installed.  You will find this the same with the pure Continuum Anaconda distribution, of which I have several covering all the versions that I may have to work with.  The only difference is... if you want to use 'arcpy' , then esri sets the rules because they have to maintain their whole conda package.

As for workflow, I can choose to do whatever I want with any version of python within its own conda distribution (ie continuum's 3.4, 3.5 and 3.6 distributions), then when I need something done in ArcPRO or even ArcMap, I just bring the data into esri's distribution of packages.  I have never had a problem, in fact, I could quite comfortably use theirs solely, since packages such as gdal and the other open source packages that try to circumvent arc*anything aren't needed in my workflow, since I have access to arcpy. 

If you could provide a specific case where you can't do something in 'python' that would be an issue.  If you are talking about something that you can't do in your workflow because of your chosen packages, then perhaps suggestions can be made as to alternatives within the existing esri conda distribution or other options within a continuum distribution or how to conda or pip install what you need.  For example, gdal is quite old school only relying on numpy 1.0, and the whole raster-array-raster translation is readily handled.  The only stumbling block may be in geodatabase support, but since you have arc* then that shouldn't be an issue.

The whole point of my missives, is that you can do anything you want within the confines of the PRO distribution... anything that isn't there, simple solutions exist and having the 'newest' continuum anaconda distribution provides the opportunity to plan ahead and/or exploit capabilities when they appear.

Give it a try, just keep your installations clean and separate and well managed.

ShaunWalbridge
Esri Regular Contributor

Bidhyananda,

I'm able to install a wide variety of packages within the Pro environment, including many other geospatial ones. Can you name any particular packages that aren't working for you?

If you have an existing external conda that you'd prefer to use, you can still use a .pth based cross-linking to achieve the same effect as before. As Dan mentioned in an earlier post on this thread, you just need to point it at the relevant locations within the Pro install to pick up (a) the ArcGIS Pro bin directory and (b) the locations of the ArcPy install. In a future release, we will make this simpler, but the same approach you've been using for ArcMap 10.x will work with Pro as well if you'd prefer not to use the Conda environment included with Pro.

PhilMorefield
Occasional Contributor III

I'm afraid I need some additional help getting this to work, as well. Like I've done for a few years now, I added a .pth file to my Miniconda distribution folder. The contents of that file are:

C:\Program Files\ArcGIS\Pro\bin
C:\Program Files\ArcGIS\Pro\Resources\ArcPy
C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\Scripts

When I try to import arcpy, however, an error is thrown:

import arcpy
Traceback (most recent call last):
  Python Shell, prompt 1, line 1
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 66, in <module>
    from arcpy.geoprocessing import gp
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from ._base import *
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module>
    import arcgisscripting
builtins.ModuleNotFoundError: No module named 'arcgisscripting'

Any assistance would be much appreciated.