Getting "PDFNet" is not defined error even after successful installation of 'apryse-sdk'

Product: PDFTron

Product Version:

Please give a brief summary of your issue:

Please describe your issue and provide steps to reproduce it:

After installing apryse-sdk via uv pip install in a Python 3.11 virtual environment, the PDFNet object remains undefined despite successful import of apryse_sdk. The native libraries (libPDFNetC.dylib and _PDFNetPython.so) are present in the package directory but fail to load.

Environment Details:

  • OS: macOS [Your Version - run sw_vers]
  • Python: 3.11.x (virtual environment)
  • Installation Method:

bash

uv pip install apryse-sdk --index-url https://pypi.apryse.com
  • File Locations:

bash

/Users/abc../Desktop/core/.venv-3.11/lib/python3.11/site-packages/apryse_sdk/

Contains: __init__.py, _PDFNetPython.so, libPDFNetC.dylib

Please provide a link to a minimal sample where the issue is reproducible:

1 Like

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


It seems you’re encountering an issue where the PDFNet object is not recognized even after installing the apryse-sdk. This could be related to how the native libraries are being loaded in your virtual environment. Let’s explore some steps to troubleshoot and resolve this issue.

Some things you can try:

  • Ensure that the virtual environment is activated correctly before running your Python script.

  • Verify that the apryse-sdk installation is complete and all necessary files are present in the site-packages directory.

  • Check the permissions of the files within the apryse_sdk directory to ensure they are accessible.

  • Try importing the apryse_sdk module and accessing the PDFNet class directly in a Python shell within the virtual environment to see if any errors are raised.

  • Consider reinstalling the apryse-sdk to ensure no installation errors occurred. Use pip uninstall apryse-sdk followed by pip install apryse-sdk --index-url https://pypi.apryse.com.

  • If the issue persists, check the environment variables to ensure that the paths to the native libraries are correctly set and accessible.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

1 Like

Hi,

Are you following our guide here:

Can you also clarify what you mean by β€œfail to load”? Are you getting an errors? Can you send any log files you have?

1 Like

Hello,

Yes, I have followed the guide to install Apryse SDK. I have Python version 3.12.8 in my virtual environment, and apryse-sdk was successfully installed. However, when I build and run the tests on GitHub Actions, I am encountering the following error:

from apryse_sdk import ColorPt, PDFDoc, PDFNet, Rect, SDFDoc, Square
ModuleNotFoundError: No module named 'apryse_sdk'

Despite the message stating that apryse-sdk was successfully installed, as shown in the GitHub Actions logs:

Requirement already satisfied: pip in /opt/hostedtoolcache/Python/3.12.9/x64/lib/python3.12/site-packages (25.0.1)
Looking in indexes: https://pypi.org/simple, https://pypi.apryse.com
Collecting apryse-sdk
Downloading https://pypi.apryse.com/apryse-sdk/apryse_sdk-11.3.0-cp312-cp312-manylinux2014_x86_64.whl (26.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 26.4/26.4 MB 66.8 MB/s eta 0:00:00
Installing collected packages: apryse-sdk
Successfully installed apryse-sdk-11.3.0

Could you help me investigate why apryse_sdk is not being found when running the tests in the CI environment despite being installed?

Thank you for your assistance!

1 Like

Hi,

You’re not supposed to be using β€œfrom apryse_sdk” but β€œfrom PDFNetPython”. Take a look at one of your Python samples for examples on how to import the module:

1 Like