How to make python calls to arcgis.gis and pandas work outside jupyter?

692
7
07-19-2018 08:15 AM
AllenGuan2
New Contributor III

My python scripts that call ArcGIS.gis and pandas module work fine in jupyter notebook. But failed when running as a standalone py file.  I used the same commands (see below) to setup the environment before launching jupyter notebook or the py file. Anything I missed for running the py file standalone?

set PATH=C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3;C:\Program Files\ArcGIS\Pro\bin\Python\Scripts;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Scripts;%PATH%
set PYTHONPATH=C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages;%PYTHONPATH%

0 Kudos
7 Replies
JeffBigos
Esri Contributor

Hi Alan,

From what I see above you are looking to access the api from the python environment installed with pro.

Take a look at the following help topic, it will outline the different ways you can access and run a stand alone script from that environment:

Run stand-alone scripts—ArcPy Get Started | ArcGIS Desktop 

Let me know if you have any questions.

Thanks, 

Jeff

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Allen, is this question related to your other one from today:  https://community.esri.com/thread/218173-error-in-importing-arcgisgis-module 

0 Kudos
AllenGuan2
New Contributor III

Yes it was related, but I am asking for a more general question.

0 Kudos
AllenGuan2
New Contributor III

Ok, don't know why, but if I replace my python script call in the bat file

BHP_AGOL_API_module_tests.py

with

"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" BHP_AGOL_API_module_tests.py

Then everything works fine, both arcgis.gis and pandas.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

That is the version of python that is associated with the anaconda distribution, hence it is the one that you should be using for Pro and ArcGIS work

0 Kudos
AllenGuan2
New Contributor III

But I thought my path setting should have taken care of it.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Allen, it is just easier to create desktop shortcuts to your python IDE (example uses spyder), Jupyter Notebook and IPython and the proenv.bat file.... see this for examples

/blogs/dan_patterson/2017/07/01/arcgis-pro-2-creating-desktop-shortcuts 

and one specifically for Jupyter

/blogs/dan_patterson/2017/07/09/arcgis-pro-2-jupyter-notebook-setup-basics 

0 Kudos