ArcGIS Pro provides access to a large collection of Python packages. To support Python packages, ArcGIS Pro includes a package management system named conda. ArcGIS Pro integrates conda with the Package Manager page. You can also access conda from a command prompt.
To further extend the versatility and utility of Python packages, multiple Python environments can coexist on a single workstation, independent of one another. Each Python environment can have its own set of packages, allowing you to switch between sets of Python functionality without uninstalling and reinstalling packages each time.
By default, ArcGIS Pro has a single conda environment, arcgispro-py3, which includes all Python libraries used by ArcGIS Pro as well as several others, such as scipy and pandas.
- Clone an environment
- Activate an environment
- Add an environment
- Delete an environment
- Upgrade an environment
- Repair an environment
- Add or remove a package
- Update a package
Attention :
La modification de l’environnement Python par défaut de ArcGIS Pro (arcgispro-py3) n’est pas conseillée et peut avoir des conséquences inattendues. Il est préférable de modifier un environnement cloné.
Licence :
For information about licensing, see Esri's licensing agreement with Anaconda.
Access conda from a command prompt
From a command prompt, you can access conda functionality using the conda command. The active Python environment is indicated in parentheses at the prompt before the current directory. Use the Python Command Prompt shortcut to open a command prompt window initialized with the active conda environment for ArcGIS Pro.
The following are examples of conda commands:
List packages in the active environment.
conda list
List all conda environments.
conda env list
Clone the default arcgispro-py3 environment to create an environment named my_env.
conda create --clone arcgispro-py3 --name my_env --pinned
To get help for a command, type the --help or -h flag after the conda command.
The --pinned flag, introduced by Esri, carries over the pinned file from the source environment to the cloned environment. Use this flag to ensure that the integrity of the cloned environment is maintained when upgrading or installing packages.
To activate an environment for your current command line session, use the activate command.
activate my_env
For more information about using and working with conda, see Introduction to conda.
In addition, ArcGIS Pro supports additional commands introduced by Esri, such as proswap and propy.
To activate an environment for your current command line session and set the environment as the new default for future ArcGIS Pro and command line sessions, use the proswap command.
proswap my_env
You can open a Python session in the active environment with the propy command and run Python scripts using the following format:
propy yourscript.py
The ArcGIS Pro environment includes conda as a stand-alone executable rather than the typical full Python distribution, which makes the ArcGIS Pro installation smaller and faster. Every time you run a conda-based command such as proswap, the conda executable will extract the files it needs to load the static build of Python into your temporary directory, identified by %TMPDIR%, %TEMP%, or %TMP% in your system environmental variables. After the command is complete, the temporary files will be removed.
Network access for creating environments and installing packages
Creating conda environments and installing packages requires an internet connection. If you're trying to clone an environment from behind a firewall, the following sites may need to be put on an allow list in your network's firewall settings:
- https://conda.anaconda.org
- https://repo.anaconda.com
Rubriques connexes
Vous avez un commentaire à formuler concernant cette rubrique ?