pythondjangodependency-managementpdfnet

How do I install PDFNet python module?


I have been running in circles trying to figure out how to get my Django app to recognise the trial version of PDFNet:

https://pypi.python.org/pypi/PDFTron-PDFNet-SDK-for-Python/5.7

I tried adding the files to my ~/usr/bin directory, I tried dropping them into my virtualenv's bin directory. Neither has worked. I have read all the documentation i can find. I am too new of a Python developer to look at this package and know how to install it and utilize it in my project.

Please help!

update I attempted to create an app folder, and list this component as an app in the app list, but when I run the code to start the application, I get the following error:

Library not loaded: @rpath/libPDFNetC.dylib

I placed all of the lib files into this folder within my project:

I used the following import code at the top of the py file I was attempting to use the component on:

import site
site.addsitedir("../pdfnetc")
from pdfnetc.PDFNetPython import *

I put the lib files into a app folder named pdfnetc. once I had this, the import statements were no longer listed as unfound by pycharm.

here is the stack trace:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2217, in <module>
    globals = debugger.run(setup['file'], None, None)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1643, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Users/ntregillus/myapp/manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/ntregillus/myapp/statements/models.py", line 12, in <module>
    from statements.managers import StatementTemplateManager, StatementManager
  File "/Users/ntregillus/myapp/statements/managers.py", line 8, in <module>
    from statements.utils import render_to_pdf, StatementContextBuilder
  File "/Users/ntregillus/myapp/statements/utils.py", line 23, in <module>
    from pdfnetc.PDFNetPython import *
  File "/Users/ntregillus/myapp/pdfnetc/PDFNetPython.py", line 28, in <module>
    _PDFNetPython = swig_import_helper()
  File "/Users/ntregillus/myapp/pdfnetc/PDFNetPython.py", line 24, in swig_import_helper
    _mod = imp.load_module('_PDFNetPython', fp, pathname, description)
ImportError: dlopen(/Users/ntregillus/myapp/pdfnetc/_PDFNetPython.so, 2): Library not loaded: @rpath/libPDFNetC.dylib
  Referenced from: /Users/ntregillus/myapp/pdfnetc/_PDFNetPython.so
  Reason: image not found

Solution

  • python -m pip install PDFNetPython3 home page link here