【发布时间】:2020-11-14 12:40:03
【问题描述】:
我安装了 ArcGIS Pro 2.5.2,并使用位于此处的解释器在 PyCharm 中创建了一个新的虚拟环境:
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe
我已将 ArcGISPro.pth 文件复制到我的虚拟环境中,以便它知道 ArcPy 的位置。当我运行一个简单的脚本时:
import arcpy
我得到以下,有点难以理解的错误:
C:\Users\lharris\PycharmProjects\arcpro_test\venv\Scripts\python.exe C:/Users/lharris/PycharmProjects/arcpro_test/test.py
arcpy must be run from inside the Conda environment, which ArcGIS
Traceback (most recent call last):
uses to manage the installation of Python.
File "C:/Users/lharris/PycharmProjects/arcpro_test/test.py", line 1, in <module>
You can access this environment by launching Python from the links inside the
import arcpy
"ArcGIS > ArcGIS Pro" Start Menu Group:
"Python Interactive Terminal" starts a Python session.
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 70, in <module>
"Python Command Prompt" opens a Command Prompt window initialized with Conda.
Or by running the proenv.bat file in the terminal:
raise ImportError("arcpy needs to run within an active ArcGIS Conda environment")
C:\> C:\Program Files\ArcGIS\Pro\bin\python\scripts\proenv.bat
ImportError: arcpy needs to run within an active ArcGIS Conda environment
Process finished with exit code 1
当我用那个 Python 解释器打开一个终端时,它会说:
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
我相信 ArcGIS Pro 已经更新(这是在工作的服务器上,所以我无法控制它)。但是,我以前导入 ArcPy 没有问题。那么,这可能是此更新版本特有的新问题吗?是不是跟 Arc 使用 Conda 有关系?
如何使用与 ArcGIS Pro 2.5.2 捆绑的 Python 版本和 PyCharm?
【问题讨论】:
标签: python pycharm arcgis arcpy