You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

同时加载ArcPy与arcgisbinding包时出现冲突问题求助

问题:R中同时加载ArcPy与arcgisbinding包冲突故障排查与解决

问题背景

此前数月运行正常,近期在R中同时加载ArcPy与arcgisbinding包时出现冲突:单独加载任一包均正常,但调整加载顺序后,最后加载的包会报错。

具体错误场景及日志

场景1:先加载arcgisbinding,再调用ArcPy

运行arcpy$CheckOutExtension("Cartography")返回错误:

C:\Users\LEON~1.THO\CONDA~1\envs\r-arcpy\lib\site-packages\numpy\__init__.py:143: UserWarning: mkl-service package failed to import,
therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been
loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service 
from . import _distributor_init

List of 22
$ python              : chr "C:/Users/leon.thoma/.conda/envs/r-arcpy/python.exe"
$ libpython           : chr "C:/Users/leon.thoma/.conda/envs/r-arcpy/python39.dll"
$ pythonhome          : chr "C:/Users/leon.thoma/.conda/envs/r-arcpy"
$ pythonpath          : chr "C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcPy;C:\\Users\\LEON~1.THO\\CONDA~1\\envs\\r-arcpy\\python39.zip;C:"| __truncated__
$ prefix              : chr "C:\\Users\\LEON~1.THO\\CONDA~1\\envs\\r-arcpy"
$ exec_prefix         : chr "C:\\Users\\LEON~1.THO\\CONDA~1\\envs\\r-arcpy"
$ base_exec_prefix    : chr "C:\\Users\\LEON~1.THO\\CONDA~1\\envs\\r-arcpy"
$ virtualenv          : chr ""
$ virtualenv_activate : chr ""
$ executable          : chr "C:\\Users\\LEON~1.THO\\CONDA~1\\envs\\r-arcpy\\python.exe"
$ base_executable     : chr "C:\\Users\\LEON~1.THO\\CONDA~1\\envs\\r-arcpy\\python.exe"
$ version_string      : chr "3.9.18 [MSC v.1931 64 bit (AMD64)]"
$ version             : chr "3.9"
$ architecture        : chr "64bit"
$ anaconda            : logi FALSE
$ conda               : chr "True"
$ numpy               :List of 2
  ..$ path   : chr "C:/Users/leon.thoma/.conda/envs/r-arcpy/Lib/site-packages/numpy"
  ..$ version:Class 'numeric_version'  hidden list of 1
  .. ..$ : int [1:3] 1 20 1
$ required_module     : chr "arcgis"
$ required_module_path: chr "C:\\Users\\LEON~1.THO\\CONDA~1\\envs\\r-arcpy\\lib\\site-packages\\arcgis\\__init__.p"
$ available           : logi TRUE
$ python_versions     : chr "C:/Users/leon.thoma/.conda/envs/r-arcpy/python.exe"
$ forced              : chr "import(\"arcgis\")"
- attr(*, "class")= chr "py_config"
Error in `map()`:
ℹ In index: 1.
Caused by error in `map()`:
ℹ In index: 1.
Caused by error:
! Python module arcpy was not found.

Detected Python configuration:

按照提示安装mkl-service后,返回结果:

## Using --user flag workaround when installing mkl-service due to permission restrictions
python -m pip install --user mkl-service
Requirement already satisfied: mkl-service in c:\programdata\anaconda3\lib\site-packages (2.3.0)
Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from mkl-service) (1.15.0)

场景2:先加载ArcPy,再调用arcgisbinding

运行arcgisbinding::arc.check_product()返回错误:

Error: Could not bind to a valid ArcGIS Pro installation.

环境配置信息

  • ArcGIS Pro版本:3.1
  • arcgisbinding版本:1.0.1.306
  • R版本:4.3.1 (2023-06-16 ucrt),运行环境Windows 10 x64 (build 19045)
  • RStudio默认Python解释器:自动构建的conda环境'r-arcpy'(Python 3.9.18)
  • 所有场景下reticulate::py_config()返回结果一致:
python:         C:/Users/leon.thoma/.conda/envs/r-arcpy/python.exe
libpython:      C:/Users/leon.thoma/.conda/envs/r-arcpy/python39.dll
pythonhome:     C:/Users/leon.thoma/.conda/envs/r-arcpy
version:        3.9.18 [MSC v.1931 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:/Users/leon.thoma/.conda/envs/r-arcpy/Lib/site-packages/numpy
numpy_version:  1.20.1
arcgis:         C:\Users\LEON~1.THO\CONDA~1\envs\r-arcpy\lib\site-packages\arcgis\__init__.p

NOTE: Python version was forced by use_python() function

解决方案建议

  • 隔离会话加载:使用不同的R会话分别处理ArcPy和arcgisbinding相关任务,避免同一会话中同时加载两个包。
  • 重置Python绑定:加载第一个包后,强制重置reticulate的Python环境绑定,再加载第二个包:
    # 加载第一个包后执行
    reticulate::py_disconnect()
    reticulate::use_python("C:/Users/leon.thoma/.conda/envs/r-arcpy/python.exe", required = TRUE)
    # 再加载第二个包
    
  • 更新依赖版本:将arcgisbinding更新至最新版本,同时确保conda环境'r-arcpy'中的ArcPy、numpy等依赖与ArcGIS Pro 3.1版本兼容。
  • 检查环境变量:确认ArcGIS Pro相关系统环境变量(如ARCGIS_PRO_PATH)在R会话中正确配置,避免路径冲突。
  • 重建conda环境:删除并重新构建'r-arcpy'环境,确保所有依赖完整且版本匹配:
    conda remove --name r-arcpy --all
    conda create --name r-arcpy python=3.9
    # 安装ArcPy及对应依赖
    

内容的提问来源于stack exchange,提问作者L.Thoma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 15:19:55