Discussion:
[conda] Cannot import Esri's arcpy into jupyter notebook
Hugo
2017-04-06 03:55:51 UTC
Permalink
Hi

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

https://gisday.wordpress.com/2016/07/18/setting-up-anaconda-pysal-with-arcgis-python-environment/

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
--
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+***@continuum.io.
To post to this group, send email to ***@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.
Rich Signell
2017-04-07 02:33:51 UTC
Permalink
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
Post by Hugo
Hi
I have followed instructions about making anaconda compatible with Esri's
arcpy implementation in
https://gisday.wordpress.com/2016/07/18/setting-up-anaconda-pysal-with-arcgis-python-environment/
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
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 #
---> 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
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
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
--
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
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.
--
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+***@continuum.io.
To post to this group, send email to ***@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/CAO4M2uO3oHdJwep30eH0H5Ay4Z5_0y-rcoMKxaqsWTdUDACNvg%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
XL
2018-09-07 02:36:43 UTC
Permalink
Another simple way is using archook package. It can be called using pip
directly from Jupyter Notebook.

Post by Hugo
Hi
I have followed instructions about making anaconda compatible with Esri's
arcpy implementation in
https://gisday.wordpress.com/2016/07/18/setting-up-anaconda-pysal-with-arcgis-python-environment/
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
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
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
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
--
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+***@continuum.io.
To post to this group, send email to ***@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/9f2e5764-0e0b-4f68-a7b5-b71edc618624%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
Loading...