通过pip、pipenv或conda安装arcgis时遇类型错误求助
解决ArcGIS Python包安装时的setup.py TypeError错误
问题重现
尝试以下命令安装ArcGIS包均失败:
py -m pipenv install arcgispy -m pip install arcgisconda install -c esri arcgis
错误表现:下载arcgis-2.0.0.tar.gz完成后,准备元数据(setup.py)失败,报错subprocess-exited-with-error,Traceback指向setup.py第193行的TypeError: unsupported operand type(s) for +: 'NoneType' and 'str',且提示问题源自arcgis包本身。
可能原因及解决方案
1. 指定安装兼容的ArcGIS版本
arcgis-2.0.0版本的setup.py存在已知环境检测bug,建议安装更稳定的旧版本:
- 使用pip安装指定版本:
py -m pip install arcgis==1.9.1 - 使用conda安装指定版本:
conda install -c esri arcgis=1.9.1
2. 检查Python版本兼容性
ArcGIS 2.0.0仅支持Python 3.8-3.10版本,若当前Python版本不在此范围内会触发这类错误:
- 查看当前Python版本:
py --version - 版本不兼容时,创建对应版本的虚拟环境再安装:
py -m venv arcgis-env arcgis-env\Scripts\activate py -m pip install arcgis
3. 手动修复setup.py(临时方案)
若必须安装2.0.0版本,可手动处理:
- 下载
arcgis-2.0.0.tar.gz并解压 - 找到setup.py第193行,针对路径拼接逻辑添加None值判断,比如:
# 原代码示例 target_path = some_var + "/arcgis_core" # 修改为 target_path = (some_var or "") + "/arcgis_core" - 本地安装修改后的包:
py -m pip install ./arcgis-2.0.0
内容的提问来源于stack exchange,提问作者Heather
相关产品推荐
相关产品推荐

