1、确认ArcGIS Pro的python版本
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
我的是Python3.9.11,64 bit
2、确认Anaconda的python版本
我的是Python3.8.3,64 bit
不需要更改环境为32 bit,只需要创建Anaconda的Python版本为Python3.9.11的虚拟环境。
3、在Anaconda中创建Python 3.9.11环境
(1)创建环境
conda create --name arcpyPro3.0 python=3.9.11
(2)删除环境
conda remove -n arcpyPro3.0 --all
(3)查询创建的环境
conda env list
可以参考下面博主,解决环境位置的问题。
4、激活环境
conda activate arcpyPro3.0
5、安装ArcGIS Pro API for Python
conda install -c esri arcgispro=3.0
6、在线安装
conda install -c esri arcpy=3.0
7、离线安装
访问:Package repository for esri :: Anaconda.org
找到对应的文件
Files里有之前的版本,匹配自己的版本,我的是win-64/arcpy3.0-py39_arcgispro_36056.tar.bz2
安装离线的安装包
conda install D://arcpy-3.0-py39_arcgispro_36056.tar.bz2
这个主要原因是离线包不能是其他文件一般是.conda或者.tar.bz2
错误提示:CondaValueError: cannot mix specifications with conda package filenames
8、安装spyder
conda install spyder
9、打开spyder,输入import arcpy
在Anaconda Powershell Prompt (Anaconda3)输入import arcpy,会提示“FNP preptool has not been run on this executable”。
对FNP preptool has not been run on this executable解决办法:申请或购买正版,可参考:使用arcpy时,FNP preptool has not been run on this executable问题解决办法_GIS小小研究僧的博客-CSDN博客qhttps://blog.csdn.net/weixin_43416590/article/details/124921305其他参考博客:Spyder中如何导入并使用arcpy_spyder acrpy-CSDN博客