Cannot import Esri's arcpy into jupyter notebook

1 view
Skip to first unread message

Hugo

unread,
Apr 5, 2017, 11:55:52 PM4/5/17
to conda - Public
Hi 

I have followed instructions about making anaconda compatible with Esri's arcpy implementation in  


In particular I have imported all the .pth files from python to anaconda and vice versa (but I have put them in the site-packages folders, as I found some other instructions about that.)

When I open a jupyter notebook and try the import statement i.e. 

import arcpy

I get the following error: 

ImportError                               Traceback (most recent call last)
<ipython-input-1-50d283eebbb3> in <module>()
----> 1 import arcpy

C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\__init__.py in <module>()
     20 import numpy
     21 
---> 22 from arcpy.geoprocessing import gp
     23 from arcpy.geoprocessing import env
     24 from arcpy.geoprocessing._base import gptooldoc as _gptooldoc

C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\geoprocessing\__init__.py in <module>()
     12 #
     13 #email: 
---> 14 from _base import *

ImportError: No module named '_base'

I am on ArcGIS Desktop 10.5 and anaconda 3. Note however that I also have ArcGIS for Server, ArcGIS Pro and Portal for ArcGIS installed in the same environment.  

I have tried to add several path entries into the .pth file I import into the site-packages folder of anaconda, but some of them stop the jupyter notebook from firing up altogether. 

By default, by desktop.pth file from Esri't python installation contains the following entries: 

C:\Program Files (x86)\ArcGIS\Desktop10.5\bin
C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy
C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcToolBox\Scripts

I have executed, in the Esri environment: 

import sys
print.sys.path

and then added all the returned path entries to the desktop.pth file in the anaconda site-packages folder, but when I do this, the jupyter notebook fails to open.   

Can anyone help? 

Thanks

Hugo      

Rich Signell

unread,
Apr 6, 2017, 10:33:53 PM4/6/17
to Hugo, conda - Public
ArcPro now uses Miniconda, so that should be easy.

Also check out these tips:
https://my.usgs.gov/confluence/pages/viewpage.action?pageId=540116867
---
Rich Signell
81 Queen St
Falmouth, MA 02540
> --
> You received this message because you are subscribed to the Google Groups
> "conda - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to conda+un...@continuum.io.
> To post to this group, send email to co...@continuum.io.
> Visit this group at https://groups.google.com/a/continuum.io/group/conda/.
> To view this discussion on the web visit
> https://groups.google.com/a/continuum.io/d/msgid/conda/d3c0e0a9-4d26-4526-baa3-8f3fc628410f%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

XL

unread,
Sep 6, 2018, 10:36:43 PM9/6/18
to conda - Public
Another simple way is using archook package. It can be called using pip directly from Jupyter Notebook.
Reply all
Reply to author
Forward
0 new messages