I am trying to set up a new python project that uses pipenv to manage my package dependencies. I'm getting the following error when trying to import arcpy within the virtual environment generated by pipenv:
arcpy must be run from inside the Conda environment, which ArcGIS
uses to manage the installation of Python.
You can access this environment by launching Python from the links inside the
"ArcGIS > ArcGIS Pro" Start Menu Group:
"Python Interactive Terminal" starts a Python session.
"Python Command Prompt" opens a Command Prompt window initialized with Conda.
Or by running the proenv.bat file in the terminal:
C:\> C:\Program Files\ArcGIS\Pro\bin\python\scripts\proenv.bat
Traceback (most recent call last):
File "main.py", line 1, in <module>
import arcpy
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 70, in <module>
raise ImportError("arcpy needs to run within an active ArcGIS Conda environment")
ImportError: arcpy needs to run within an active ArcGIS Conda environment
I have followed the pipenv documentation for using "other python distributions" and entered the following command to establish my new python environment:
pipenv --python="C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe" --site-packages
According to the documentation, pointing pipenv to the location of the arcgispro-py3 binary and adding the --site-packages flag should be enough to create a new python environment with the arcpy site package available.
I'm hoping an Esri rep can help solve this issue. The only documentation I've seen from Esri is related to pipenv and the ArcGIS API for Python, but I need arcpy for my project.