Open Menghetz opened 7 months ago
Do you have a file called pyrfc.py
in your project root?
Is SAPNWRFC_HOME set correctly?
What does the following print?
import pyrfc
import sys
import os
print(1, os.environ.get('SAPNWRFC_HOME'))
print(2, sys.modules['pyrfc'].__file__)
print(3, pyrfc.__version__)
I have a simmilar problem.
I reproduced the error with the Dockerfile: redhat.ubi8.Dockerfile
FROM redhat/ubi8:8.9-1160
RUN yum update -y && yum upgrade -y && \
yum install -y gcc gcc-c++ python3 python3-devel python3-pip unzip git
# INSTALL sap nwrfc sdk: https://sap.github.io/PyRFC/install.html#sap-nwrfc-sdk-installation
COPY ./nwrfc750P_13-70002752.zip /usr/local/sap/nwrfc750P_13-70002752.zip
RUN unzip /usr/local/sap/nwrfc750P_13-70002752.zip -d /usr/local/sap/
ENV SAPNWRFC_HOME=/usr/local/sap/nwrfcsdk
RUN echo "/usr/local/sap/nwrfcsdk/lib" > /etc/ld.so.conf.d/nwrfcsdk.conf && \
ldconfig
# INSTALL pyrfc build tools: https://sap.github.io/PyRFC/build.html#toolchain-preparation
RUN python3 -m pip --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org install build cython wheel pytest sphinx
# BUILD pyrfc from source: https://sap.github.io/PyRFC/build.html#build-from-source
RUN git clone -b v3.3.1 https://github.com/SAP/PyRFC.git /pyrfc && cd /pyrfc && python3 -m pip --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org install .
# Example usage: https://sap.github.io/PyRFC/intro.html#example-usage
docker build -t pyrfc:redhat.ubi8 -f redhat.ubi8.Dockerfile .
docker run -it --rm --name pyrfc_on_redhat pyrfc:redhat.ubi8 /bin/bash
python3
from pyrfc import *
from pyrfc import Connection
Output:
# python3
Python 3.6.8 (default, Jan 5 2024, 08:58:17)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyrfc import *
>>> from pyrfc import Connection
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Connection'
@sebastiantaurer seems you are running Python 3.6.8
pyrfc 3.3.1 requires Python >=3.8
Describe the bug I'm trying to implement pyrfc in my python project, but after the installations of the library, I can't call the connection through import.
To Reproduce python -m venv venv .\venv\Scripts\activate pip install pyrfc
Create a file call main.py import pyrfc conn = Connection(ashost='10.0.0.1', sysnr='00', client='100', user='me', passwd='secret') Screenshots
Environment
Additional context Add any other context about the problem here.