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?
Solved! Go to Solution.
Phil,
The installation that comes with Pro includes Miniconda, you can create environments from within it which include all of the ArcGIS Pro dependencies by running
conda create --name myenv --clone arcgispro-py3
But if you have specific needs which require an external Miniconda, yes, you're right. I neglected an additional step that is needed with Pro 1.3 and 1.4. The C extensions which drive Pro would also need to be copied (in addition to the .pth file). Assuming Pro is installed into Program Files, you could use this batch script:
set DEST=c:\Anaconda\envs\myenv\lib\site-packages cd "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages" copy arcgisscripting.pyd %DEST% copy gapy.pyd %DEST% copy arcpy_wmx.pyd %DEST%
Let me know if either of the approaches above work for you, or if you have any further problems creating new environments which talk to Pro. We're in the process of revamping this so these steps won't be necessary in a future release.
Cheers, Shaun
Hi Shaun Walbridge. I tried the first approach - cloning the arcgis pro. But the cloning process got stuck at some point so I could not finish the cloning process. I think the issue was that I had already installed additional packages both using Pro and also from outside using conda/pip etc. So I think one of these packages (geos or something similar) was a problem.
Anyway here is my question. Say I successfully the clone the ArcGIS Pro in my new environment "myenv." Can I now use "myenv" for all my Python work such as using arcpy, installing additional third party libraries etc. I am just curious how the licensing will work for arcpy because now you are in a new environment.
Yes, you can make any number of environments, there's no constraints with regards to licensing. They can even operate at the same time, provided you have sufficient resources available.
On the cloning, it sounds like perhaps conda had an issue making a copy of the environment. As a quick and dirty alternative, you could try copying the directory and renaming it to something else, that should work (though once we have a robust way of making environments with ArcPy included, that'll be preferable).
Cheers, Shaun
I tried using the batch script you suggested, but I'm still getting the same error (basically):
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.ImportError: DLL load failed: The specified module could not be found.
Shouldn't those libraries be importable without copying, since I had already added the containing directory to the .pth file?
Phil,
Yes, there's one additional step I neglected. You'll need the ArcGIS Pro bin directory to be registered as part of the path that Pro sees. You can do this a few ways, perhaps the simplest is to add it to your global path (C:\Program Files\ArcGIS\Pro\bin). If you'd rather not modify the global path, you can also add it to the lib\site.py file for the environment you created, or add another pth file, let's call it ArcGISProBin.pth:
import os; import sys; d = r'c:\Program Files\ArcGIS\Pro\bin'; os.environ["PATH"] = r"{};{}".format(d, os.environ["PATH"])
This is still a pain point and something we expect to improve in the near future.
Thanks,
Shaun
Shaun this solution worked for me! Yes, a "pain point"!!
The reason I need to do this is because the conda environment is not available to me as a regular user.
In our agency elevated access is reserved for software installs and is strongly discouraged for day-to-day work. Most people do not have admin access.
@ Phil Morefield did you find solution to your problem. I guess I followed some suggestions from stack overflow and now getting a new error
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py", line 22, in <module>
from arcpy.geoprocessing import gp
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
ModuleNotFoundError: No module named '_base'
Please let me know if anyone has fixed this issue.
No, I was never able to get the instructions on this page to work. I'm just going to continue to stick with Python 2.x and ArcGIS 10.x until the process is simplified for Python 3.x/ArcGIS Pro.
With the release of ArcGIS Pro 2.0, is the process of installing and running the arcpy from outside a little bit easier? I would appreciate some feedback if anyone has tried running new arcpy with Pro 2.0.
Bidhyananda,
We've made some progress toward this goal, but unfortunately the simple solution isn't available yet. We anticipate having a simpler solution for the Pro 2.1 release.