Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module 'pyrfc' has no attribute Connection #365

Open
Menghetz opened this issue Apr 10, 2024 · 3 comments
Open

Module 'pyrfc' has no attribute Connection #365

Menghetz opened this issue Apr 10, 2024 · 3 comments

Comments

@Menghetz
Copy link

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
image

Environment

  • OS: Windows 10 Enterprise
  • Running in docker? NO
  • PyRFC version : 3.3.1

Additional context
Add any other context about the problem here.

@mpf82
Copy link

mpf82 commented Apr 15, 2024

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__)

@sebastiantaurer
Copy link

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
  • Build the docker image: docker build -t pyrfc:redhat.ubi8 -f redhat.ubi8.Dockerfile .
  • Run a docker container: docker run -it --rm --name pyrfc_on_redhat pyrfc:redhat.ubi8 /bin/bash
  • Run python inside the docker container: python3
  • Import pyrfc library: from pyrfc import *
  • Import Connection from pyrfc library: 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'

@mpf82
Copy link

mpf82 commented Apr 25, 2024

@sebastiantaurer seems you are running Python 3.6.8

pyrfc 3.3.1 requires Python >=3.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants