我一直在绕圈子,试图弄清楚如何让我的Django应用程序识别试用版的PDFNet:
https://pypi.python.org/pypi/PDFTron-PDFNet-SDK-for-Python/5.7
我尝试将这些文件添加到我的~/usr/bin目录中,然后尝试将它们放到虚拟目录中。这两种方法都没有用。我已经阅读了我能找到的所有文件。我是Python开发人员的新手,不知道如何在我的项目中安装和使用这个包。
请帮帮我!
update我试图创建一个app文件夹,并将这个组件作为应用程序列表中的一个应用程序列出,但是当我运行启动应用程序的代码时,我会得到以下错误:
库未加载:@rpath/libPDFNetC.dylib
我将所有lib文件放在我的项目中的这个文件夹中:
我在py文件的顶部使用了下面的导入代码,我试图在以下文件中使用组件:
import site
site.addsitedir("../pdfnetc")
from pdfnetc.PDFNetPython import *我将lib文件放入一个名为pdfnetc的app文件夹中。一旦我有了这个,导入语句就不再是按pycharm列出的。
下面是堆栈跟踪:
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发布于 2020-10-25 20:01:24
python -m pip install PDFNetPython3 主页链接
发布于 2020-09-09 05:55:02
下面是安装PDFNet模块的步骤:
> chmod a+x fix_rpaths.sh
./fix_rpaths.sh发布于 2015-05-01 01:42:49
我不了解django,但是仔细看看SDK中的示例py文件。例如,查看PDFNetC/Sample/AddImageTest/PYTHON文件夹。其中有一个.py文件,查看前4行代码,它们指示需要加载什么。
请注意,您需要PDFNetC/Lib文件夹中的所有文件,包括PDFNetC.dll文件。
如果这没有帮助,请张贴准确(第一)错误消息,您得到。
https://stackoverflow.com/questions/29979942
复制相似问题