I am trying to connect SAP with python with the help of PyRFC. I am referring to this guide https://blogs.sap.com/2020/06/09/connecting-python-with-sap-step-by-step-guide/ for making a connection. However, I am unable to install PyRFC in my system. I have already maintained the system variables as defined in the article and after trying to install PyRFC.tar.gz file, it is showing
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.
please help me with this.
You are getting this error because probably you have not downloaded the SAP NW RFC SDK or maybe you have not added the path of the SDK in your PATH variable.
Follow the below steps before running
pip install pyrfchttps://support.sap.com/en/product/connectors/nwrfcsdk.html
Create the SAP NW RFC SDK home directory, e.g.
c:\nwrfcsdkSet the SAPNWRFC_HOME env variable:
SAPNWRFC_HOME=c:\nwrfcsdkUnpack the SAP NW RFC SDK archive to it, e.g.
c:\nwrfcsdk\libshall exist.Include the lib directory to the library search path on Windows, i.e. extend the PATH environment variable.
For example- Add
c:\nwrfcsdk\libto PATH.Reboot your system
Download the
.whlfile from this URL - https://github.com/SAP/PyRFC/releases/download/2.0.0/pyrfc-2.0.0-cp38-cp38-win_amd64.whlInstall pyrfc by running the below command as Administrator from the same folder location where you downloaded the
.whlfile.command -
pip install pyrfc-2.0.0-cp38-cp38-win_amd64.whlIf you have followed the above steps in the given order it should work now.
Reference : https://sap.github.io/PyRFC/install.html
P.S I faced a similar issue earlier and fixed it similar way .
Here is my question - Python - pyrfc 1.9.5 - importerror while calling from IIS hosted .NET Core api