AIX Open Source

 View Only

 Issue in running Openssl and PyPDF2 module

Sujaya Nambiar's profile image
Sujaya Nambiar posted Tue May 20, 2025 04:21 AM


We created a virtual environment with system-site-packages and trying to run 2 python scripts.
1. First script errors out with the below message:
reader = PyPDF2.PdfReader(file)
AttributeError: module 'PyPDF2' has no attribute 'PdfReader'

2. Second script errors with below message:   
_ASN1 = OpenSSL.crypto.FILETYPE_ASN1
AttributeError: module 'OpenSSL' has no attribute 'crypto'

Here  are the versions we have in the system:

root@XXXXX:/root #/opt/freeware/bin/python3 -m pip list
Package            Version
------------------ ---------
attrs              19.3.0
certifi            2025.1.31
cffi               1.13.2
charset-normalizer 3.4.1
cryptography       44.0.2
hypothesis         4.47.4
idna               3.10
maturin            1.7.0
pip                25.1.1
pycparser          2.19
PyJWT              2.10.1
pyOpenSSL          25.0.0
PyPDF2             3.0.1
requests           2.32.3
semantic-version   2.10.0
setuptools         65.5.1
setuptools-rust    0.12.1
tomli              2.0.1
typing_extensions  4.13.1
urllib3            2.3.0
wheel              0.45.1
root@XXXXX:/root #/opt/freeware/bin/python3

Please assist on the error. The same script runs fine in Windows.

Ranjit Ranjan's profile image
Ranjit Ranjan

Hello,

Please share the steps you used for creating virtual environment and steps you used to install PyPDF2.

# python3
Python 3.9.20 (main, Sep 27 2024, 03:16:26) 
[GCC 10.3.0] on aix
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenSSL
>>> _ASN1 = OpenSSL.crypto.FILETYPE_ASN1
>>> 
>>> 

Thanks
Ranjit

Sujaya Nambiar's profile image
Sujaya Nambiar

--Using this command to create the venv named "test"
/opt/freeware/bin/python3.9 -m venv /int/tmp/test--system-site-packages
--activating
. /int/tmp/test/bin/activate

PyPDF2 has been installed using pip from our internal FRS Artifactory.

Ranjit Ranjan's profile image
Ranjit Ranjan

Try creating fresh virtual env and install below version of package . I don't see the issue you mentioned here. At least not from python cli prompt.

# python3 -m pip list | grep -i -E 'pyOpenSSL|PyPDF2'
pyOpenSSL                     25.1.0
PyPDF2                        3.0.1

# python3 
Python 3.9.20 (main, Sep 27 2024, 03:16:26) 
[GCC 10.3.0] on aix
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyPDF2 import PdfReader
>>> reader = PdfReader("/ranjit/sample.pdf")
>>> 
>>> from PyPDF2 import PdfReader
>>> number_of_pages = len(reader.pages)
>>> print(number_of_pages)
1
>>> import OpenSSL
>>> _ASN1 = OpenSSL.crypto.FILETYPE_ASN1
>>> exit()