I would like to convert html to pdf using pdfkit, but when i try to run in lambda i got the errors
No wkhtmltopdf executable found: ""
If this file exists please check that this process can read it or you can pass path to it manually in method call, check README. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
Traceback (most recent call last):
File "/opt/python/lib/python3.8/site-packages/pdfkit/configuration.py", line 35, in __init__
with open(self.wkhtmltopdf) as f:
FileNotFoundError: [Errno 2] No such file or directory: ''
My code:
import pdfkit
pdfkit.from_string(html_content, "testing.pdf")
the code is runing in my local py file, but not working in aws lambda. Any idea to solve this issue? or any other lib suggestions???
Thank You
You need a add wkhtmltopdf layer to your lambda function. You can get it from here https://wkhtmltopdf.org/downloads.html#stable
And in your python code add the config to pdfkit like below
PATH_WKHTMLTOPDF = '/opt/bin/wkhtmltopdf'
PDFKIT_CONFIG = pdfkit.configuration(wkhtmltopdf=PATH_WKHTMLTOPDF)
pdfkit.from_string('somehtml',configuration=PDFKIT_CONFIG)
Related
I'm writing my faceswap restAPI that use dlib to predict face landmarks. So I tried to deploy my project to Heroku and I can't do this becase I'm getting in Release phase.
File "/app/api/faceswap.py", line 39, in <module>
predictor = dlib.shape_predictor(PREDICTOR_PATH)
RuntimeError: Unable to open shape_predictor_68_face_landmarks-1.dat
As you can see I'm getting the runtime error about predictor file with ".dat" extension.
Please tell me how can I fix this error or advise other ways to deploy.
Thank you for your attention.
So, all you need to do is check the path to file on heroku cli after deploying and change it in your code.
(It was) PREDICTOR_PATH = r"C:\RestAPI_v2\shape_predictor_68_face_landmarks.dat"
(Solution) PREDICTOR_PATH = r"/app/shape_predictor_68_face_landmarks.dat"
i've been trying to install the api but it's not working
kept getting this error
stdin:1: module 'Desktop/luafilesystem-master' not found:
no field package.preload['Desktop/luafilesystem-master']
no file '/usr/local/share/lua/5.3/Desktop/luafilesystem-master.lua'
no file '/usr/local/share/lua/5.3/Desktop/luafilesystem-master/init.lua'
no file '/usr/local/lib/lua/5.3/Desktop/luafilesystem-master.lua'
no file '/usr/local/lib/lua/5.3/Desktop/luafilesystem-master/init.lua'
no file './Desktop/luafilesystem-master.lua'
no file './Desktop/luafilesystem-master/init.lua'
no file '/usr/local/lib/lua/5.3/Desktop/luafilesystem-master.so'
no file '/usr/local/lib/lua/5.3/loadall.so'
no file './Desktop/luafilesystem-master.so'
stack traceback:
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
also i can't install luarocks for the simple installing i just need it to be a stand alone program so it will temporary , be installed and it can be portable.
You seem to be loading the module as Desktop/luafilesystem-master, but in most cases it should be require "lfs" and you should have lfs.so file available in one of those paths listed in the error message.
If you are compiling from the source, then the result of that compilation will be lfs.so file that you need to place in one of those locations.
i'm trying to include plone.app.debugtoolbar into my plone4.2 buildout, but running into the same "ImportError: No module named paste.evalexception" described near the end of Martin's announcement: http://plone.293351.n2.nabble.com/ANN-plone-app-debugtoolbar-td6988915.html. this made me think the dependency had been fixed but i'm still getting it?
File "/home/rik/Plone/buildout-cache/eggs/plone.app.debugtoolbar-1.0a2-py2.7.egg/plone/app/debugtoolbar/browser/interactive.py", line 10, in <module>
from paste.evalexception import evalcontext
zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/home/rik/Plone/zeocluster/parts/client1/etc/site.zcml", line 16.2-16.23
ZopeXMLConfigurationError: File "/home/rik/Plone/buildout-cache/eggs/Products.CMFPlone-4.2.0.1-py2.7.egg/Products/CMFPlone/configure.zcml", line 102.4-106.10
ZopeXMLConfigurationError: File "/home/rik/Plone/buildout-cache/eggs/plone.app.debugtoolbar-1.0a2-py2.7.egg/plone/app/debugtoolbar/configure.zcml", line 10.2-10.32
ZopeXMLConfigurationError: File "/home/rik/Plone/buildout-cache/eggs/plone.app.debugtoolbar-1.0a2-py2.7.egg/plone/app/debugtoolbar/browser/configure.zcml", line 113.4-120.10
ImportError: No module named paste.evalexception
does this require some patch, pinning of paster...?
Simply adding an explicit dependency on Paste to my buildout:
devtools =
...
Paste
plone.app.debugtoolbar
did the trick! i'm still not sure why this dependency isn't/can't be part of plone.app.debugtoolbar, but it does seem to be a totally intra-buildout issue and unrelated to the 'external' shell's python, as #Martijn and i pursued above.
You are missing the Paste egg; in some cases, this egg is nested inside a development egg within your buildout which confuses buildout and it won't install it.
The work-around is to install it manually:
python -m easy_install Paste
I'm going through the GAE webapp2 tutorial (runtime 2.7) using GoogleAppEngineLauncher on my Mac, and though I'm following everything exactly, I keep on getting an error at the point where we import the Jinja2 module: Using Templates - Google App Engine
Error:
Traceback (most recent call last): File
"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py",
line 168, in Handle handler =
_config_handle.add_wsgi_middleware(self._LoadHandler()) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py",
line 206, in _LoadHandler handler = import(path[0]) File
"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",
line 640, in Decorate return func(self, *args, **kwargs) File
"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",
line 1756, in load_module return self.FindAndLoadModule(submodule,
fullname, search_path) File
"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",
line 640, in Decorate return func(self, *args, **kwargs) File
"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",
line 1628, in FindAndLoadModule description) File
"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",
line 640, in Decorate return func(self, *args, **kwargs) File
"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",
line 1571, in LoadModuleRestricted description) File
"/Users/ykessler/Dropbox/appgrinders/gae_apps/helloworld2.7/helloworld.py",
line 9, in import jinja2 ImportError: No module named jinja2
So it for some reason can't find the module, even though it's supposed to be packaged as part of webapp2's extras. When I do a search on my file system it looks like it's there:
/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2_extras/jinja2.py
And if I deploy the app to GAE, it works fine. Why would it be failing locally?
webapp2 packages its own jinja2 'glue' module, which is what you're importing, but it doesn't package jinja2 itself. If you want to use it, you'll need to install it in your system Python using easy_install, or put it in your app's directory.
Don't use the latest parameter on the app.yaml file, specify a version to prevent a highly unlikely but nonetheless possible incompatibility catastrophe.
Alias, specify 2.6, which is the only one supported, acording to the docs.
libraries:
- name: jinja2
version: "2.6"
Then, at your script, just import jinja2, as we're told by the docs.
I got this error too, to fix it I needed to add jinja2 to the bottom of my app.yaml file (as it says at the start of the tutorial .. )
First add the following to the bottom of helloworld/app.yaml:
libraries:
- name: jinja2
version: latest
At long last(!) I've compiled Boost::Python and have gotten my XCode project to import a local module. This module starts with the line from xml.dom import minidom, but when it executes, I'm given this error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "FeedStore.py", line 1, in <module>
from xml.dom import minidom
ImportError: No module named xml.dom
However, I know that I've installed the xml Python module -- when I open Python from my command prompt and type from xml.dom import minidom, everything goes smoothly. Moreover, when I import the module, it behaves as I would expect.
I suspected that there was something wrong with sys.path, so I compared the one I get from the prompt to the one that's being used in my embedded module. The only difference is that the embedded sys.path does not include ''. I've tried appending it, but that didn't change the behavior.
I also suspected that the embedded version was accessing a different version of Python than I was using from the prompt, but sys.prefix matched between both executions.
Here's the code that imports my module and runs it. It's pretty bare-bones at the moment (not even reference counting yet) because at this point I'd just like to make sure I'll be able to embed my module (I'm a total newbie C++ programmer).
Py_Initialize();
//PyRun_SimpleString("import sys");
//PyRun_SimpleString("sys.path.append('')"); //tried this to no avail!
PySys_SetPath("/Users/timoooo/Documents/Code/TestEmbed/"); //this allows me to import my local module
PyRun_SimpleString("import FeedStore as fs"); //here's where it whines about the lack of xml.dom
PyRun_SimpleString("store = fs.feedStore()");
PyRun_SimpleString("print store.next()");
Py_Finalize();
I'm probably misunderstanding something essential about boost::python. Can anyone help me out?
Despite having identical sys.path values, calling
PyRun_SimpleString("sys.path.append(\"<<path>>\")");
with the places I needed fixed the problem.