Create cloned conda environment as user

7436
18
Jump to solution
06-14-2017 12:55 PM
curtvprice
MVP Esteemed Contributor

I am not allowed admin access, but I really want to be able to use pro's Conda environment. Currently my only option is to run another Conda install, but in theory, can't I clone the Pro environment to a folder have access to?

Conda suggests this:

Error: Missing write permissions in: C:\ArcGIS\Pro\bin\Python
#
# You don't appear to have the necessary permissions to update packages
# into the install area 'C:\ArcGIS\Pro\bin\Python'.
# However you can clone this environment into your home directory and
# then make changes to it.
# This may be done using the command:
#
# $ conda create -n my_arcgispro-py3 --clone=C:\ArcGIS\Pro\bin\Python\envs\arcgispro-py3

but if I try it I get an error message:

PermissionError: [WinError 5] Access is denied: 'C:\\ArcGIS\\Pro\\bin\\Python\\nvs\\my_arcgispro-py3'

Is this possible? 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ClintonDow1
Occasional Contributor II

Currently it's not supported, we are moving towards enabling that sort of environment creation as soon as possible but there has been a lot to change behind the scenes, since many different parts of Pro use Python in different ways. Currently the env needs to be within the Pro folder structure to find all the pyd/DLL files that arcpy needs to initialize. If all goes according to plan this should be fixed for 2.1. 

Currently you can use the 'prefix' switch on conda create (-p) to clone the env somewhere outside the Pro folder structure, but will have to ensure the system PATH variable includes all of the locations of the DLLs to successfully import arcpy, but its not something we're officially supporting since its a bit of a hack. 

View solution in original post

18 Replies
ClintonDow1
Occasional Contributor II

Currently it's not supported, we are moving towards enabling that sort of environment creation as soon as possible but there has been a lot to change behind the scenes, since many different parts of Pro use Python in different ways. Currently the env needs to be within the Pro folder structure to find all the pyd/DLL files that arcpy needs to initialize. If all goes according to plan this should be fixed for 2.1. 

Currently you can use the 'prefix' switch on conda create (-p) to clone the env somewhere outside the Pro folder structure, but will have to ensure the system PATH variable includes all of the locations of the DLLs to successfully import arcpy, but its not something we're officially supporting since its a bit of a hack. 

curtvprice
MVP Esteemed Contributor

Clinton, thanks so much for the clear answer, really appreciate it!

0 Kudos
TobiasLitherland
New Contributor III

Hello Clinton,

Our organization uses python 3.4 for all business applications. So I obviously use the arcpy supplied with ArcGIS Pro for scripts and tools that need both GIS-functionality and access to business data. As part of this, I need to be able to access arcpy from external python environments, as we use a custom anaconda server to distribute all our api's, and this cannot be installed with ArcGIS Pro's environment.

So I was very surprised after I upgraded to ArcGIS Pro 2.0 that this feature that was external environment access was revoked. I can no longer access arcpy from outside of ArcGIS Pro. I will have to downgrade until a solution is found.

You say that there is a hack, but I cannot find information regarding this anywhere.

0 Kudos
ClintonDow1
Occasional Contributor II

Hi Tobias,

You can edit the .condarc file in %ProInstall%/bin/Python to include more than the default channels/servers which are supported on a base installation, to install packages hosted on your servers. This should allow you to install the packages into Pro environments. 

We are working on packaging arcpy for the next release of Pro to ensure it can be used anywhere on a system with the application installed. For now the workaround is ensuring the PATH (both sys.path and os.environ['PATH']) in your system conda install matches that in the Pro conda environments, which should provide arcpy with the binary files it needs to instantiate. 

DanPatterson_Retired
MVP Emeritus

An FYI for those that will be disappointed if they examine their condarc files

Configuration- Conda

ClintonDow1
Occasional Contributor II

We did evaluate adding more to the .condarc file but for every option there are potential edge cases which could be problematic, so figured it was a good idea to adhere to the minimal .condarc that comes with a base conda installation. 

DanPatterson_Retired
MVP Emeritus

I suspected as much Clinton...(since the 2 liner .condarc paled in comparison to the sys and os path info )

It would be interesting to see some of the options that were considered, but I guess I will just experiment on my own configuration since I use local everything and work local

TobiasLitherland
New Contributor III

Thanks for the reply Clinton Dow,

When I edit the .condarc-file, I would expect the list of available packages in the ArcGIS Pro Python Package Manager to change, reflecting the packages available in the new conda-sources.

What I've done is change the C:\Program Files\ArcGIS\Pro\bin\Python\.condarc - file with the following iterations:

Original:

channels:
  - esri
  - default
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

New 1:

channels:
  - esri
  - defaults
  - http://anaconda:8080/conda/company
‍‍‍‍

New 2:

channels:
  - esri
  - http://anaconda:8080/conda/company
‍‍‍‍‍‍‍‍‍‍‍‍‍

New 3:

channels:
  - http://anaconda:8080/conda/company
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

New 4:

channels:

I check the contents of ArcGIS Pro => Projects => Python => Add packages after editing .condarc:

 - None of the above condarc-files show any of the packages hosted on our anaconda server.

 - Even with a completely empty .condarc-file (New 4), nothing changes in ArcGIS Pro in the list of available packages.

So I'm not sure how ArcGIS Pro uses the references in the .condarc-file. 

I also have the company approved Miniconda installed on my machine, and that conda instance is the machine default. But ArcGIS Pro is not using this by mistake, as our Miniconda is configured to solely (and successfully) communicate with our in-house anaconda server at http://anaconda:8080/conda/company.

I would like to interact with ArcGIS Pro's conda via the command line to figure out whats going on, but I can't figure out how. Do you have any tips?

I might mention that I'm also communicating with my local Esri distributor about this issue as well, but without any luck.

The documentation for Pro and Conda seems to only cover interaction via ArcGIS Pro GUI:

The Python Package Manager—ArcPy Get Started | ArcGIS Desktop 

0 Kudos
ClintonDow1
Occasional Contributor II

Hello Tobias,

Once you have added the new channel you still have to refresh conda's metadata, its done automatically before conda runs most commands on the command line or clicking the blue circular arrow button in the UI. We ran into some complications with the metadata json files due to UAC when installed in Program Files so that experience will be improved going forward.

The conda executable that Pro is using is within the %ProInstall%/bin/Python/Scripts directory, so you can work with conda via the command line if its on your PATH. Alternatively there is a batch file which should be in the start menu in the ArcGIS program group under 'Python Command Prompt' which will open to the environment's location and activate it for you. 

Hope that helps get you in the right direction!