简体   繁体   中英

Can't install arcpy in Jupyter Notebook

I have ArcGIS Pro installed, which includes the installed Python packages. I am trying to learn Python and would like to use the ArcPy functions. I have never used Jupyter Notebook before, but to get started, I created a new Python 3 file. I entered the code to install arcpy but received an error.

pip install arcpy 
ERROR: Could not find a version that satisfies the requirement arcpy (from versions: none)
ERROR: No matching distribution found for arcpy

import arcpy
ModuleNotFoundError: No module named 'arcpy'

I know I am missing a link somewhere, and I am guessing it has to do with environments. How can I reference the arcpy packages that are installed in my ArcGIS Pro program files?

Using "Non-ArcGIS Pro" Conda Environment

I assume that you use an Anaconda or Miniconda installation not provided by ArcGIS Pro, otherwise arcpy should already be available and there is no need to install it.

Note: If you want to use ArcGIS Pro's conda environment, scroll down to Using ArcGIS Pro's Conda Enviroment or Using Jupyter Notebook from within ArcGIS Pro .

To install arcpy , you need to use conda instead of pip . As far as I know arcpy is not available in the Python Package Index ( pip 's repository).

Initial Setup

Open Anaconda Prompt (or any command prompt if conda can be found through the PATH variable).

First you need a conda environment. Use the following command to create an environment called esri-notebook (can be any name):

conda create -n esri-notebook

Then activate the environment using:

conda activate esri-notebook

Install Jupyter Lab (or Notebook) with:

conda install jupyterlab
conda update --all

Install arcpy with:

conda install arcpy -c esri

Run Jupyter Lab with:

jupyter lab

Or , run Jupyter Notebook with:

jupyter notebook

Your browser will open with Jupyter Lab or Notebook.

Using Jupyter Lab/Notebook

Open Anaconda Prompt (or any command prompt if conda can be found through the PATH variable). Activate the environment:

conda activate esri-notebook

Run Jupyter Lab with:

jupyter lab

Or , run Jupyter Notebook with:

jupyter notebook

Your browser will open with Jupyter Lab or Notebook.

Using ArcGIS Pro's Conda Enviroment

Open Python Command Prompt . arcpy is available (no setup needed).

Then start Jupyter Notebook using:

jupyter notebook

Using Jupyter Notebook from within ArcGIS Pro

You can also create a notebook from within ArcGIS Pro and arcpy should be available to use it without any further setup. Find the Python button within the Analysis ribbon:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM