无法安装 PyRFC-2.0.4

问题描述

我试图在 PyRFC 的帮助下将 SAP 与 python 连接起来。我指的是用于建立连接的指南 https://blogs.sap.com/2020/06/09/connecting-python-with-sap-step-by-step-guide/。但是,我无法在我的系统中安装 PyRFC。我已经维护了文章中定义的系统变量,在尝试安装 PyRFC.tar.gz 文件后,它显示

ERROR: Command errored out with exit status 1:
     command: 'c:\users\20035128\appdata\local\programs\python\python37\python.exe' -c 
              'import sys,setuptools,tokenize; sys.argv[0] = 
              '"'"'C:\\Users\\20035128\\AppData\\Local\\Temp\\pip-req-build-4ouyveyv\\setup.py'"'"'; 
              __file__='"'"'C:\\Users\\20035128\\AppData\\Local\\Temp\\pip-req-build-4ouy
              veyv\\setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open (__file__);
              code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();
              exec(compile(code,__file__,'"'"'exec'"'"'))' egg_info --egg-base 
              'C:\Users\20035128\AppData\Local\Temp\pip-pip-egg-info-fwk_dg_0'
         cwd: C:\Users\20035128\AppData\Local\Temp\pip-req-build-4ouyveyv\
    Complete output (1 lines):
    Environment variable SAPNWRFC_HOME not set. Please specify this variable with the root 
              directory of the SAP NW RFC Library.
    ----------------------------------------
WARNING: Discarding file:///C:/Users/20035128/Downloads/PyRFC-2.0.4.tar.gz. Command errored 
              out with exit status 1: python setup.py egg_info Check the logs for full command output.  
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for 
              full command output.

请帮我解决这个问题。

解决方法

您收到此错误的原因可能是您没有下载 SAP NW RFC SDK,或者您没有在 PATH 变量中添加 SDK 的路径。

在运行 pip install pyrfc

之前按照以下步骤操作
  1. 从以下 URL 下载 SDK-

https://support.sap.com/en/product/connectors/nwrfcsdk.html

  1. 创建 SAP NW RFC SDK 主目录,例如c:\nwrfcsdk

  2. 设置 SAPNWRFC_HOME 环境变量:SAPNWRFC_HOME=c:\nwrfcsdk

  3. 将 SAP NW RFC SDK 存档解压到其中,例如c:\nwrfcsdk\lib 应存在。

  4. 在 Windows 上将 lib 目录包含到库搜索路径中,即扩展 PATH 环境变量。

例如 - 将 c:\nwrfcsdk\lib 添加到 PATH。

  1. 重启系统

  2. 从此网址下载 .whl 文件 - https://github.com/SAP/PyRFC/releases/download/2.0.0/pyrfc-2.0.0-cp38-cp38-win_amd64.whl

  3. 通过从您下载 .whl 文件的同一文件夹位置以管理员身份运行以下命令来安装 pyrfc。

命令 - pip install pyrfc-2.0.0-cp38-cp38-win_amd64.whl

如果您按照给定的顺序执行了上述步骤,它现在应该可以工作了。

参考:https://sap.github.io/PyRFC/install.html

P.S 我之前遇到过类似的问题并以类似的方式修复它。

这是我的问题—— Python - pyrfc 1.9.5 - importerror while calling from IIS hosted .NET Core api

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...