Python pdfkit can't find wkhtmltopdf executable - python-2.7

a few months ago I had created a little script to convert URLs to PDF files, this morning I tried to convert another link but I got this error from py prompt:
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pdfkit\api.py", line 24, in from_url
configuration=configuration, cover_first=cover_first)
File "C:\Python27\lib\site-packages\pdfkit\pdfkit.py", line 42, in __init__
self.configuration = (Configuration() if configuration is None
File "C:\Python27\lib\site-packages\pdfkit\configuration.py", line 27, in __init__
'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf)
IOError: No wkhtmltopdf executable found: ""
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf -
https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
I've googled a lot but still can't find solution. Anyone can help me?

I found the solution, I don't know why but python was replacing my environment path "C:\Program Files\wkhtmltopdf\bin" with "C:\Program Files\wkhtmltopdin" because of "\b" so I just replaced "\b" with "/b" and solved.

Related

KivyMD on a Mac: running kitchen_sink raises an error in kivytoast.py

On a Macbook Pro (Catalina), Python 3.8, interested in developing Android apps in Kivy using KivyMD. I took the following steps to install KivyMD:
create the virtual environment (virtmd), then activated it (source /virtmd/bin/activate)
in this virtual environment, installed the following via pip: Pillow, kivy
git-cloned KivyMD as per the link suggested on the GitHub page
Ran the pip install .
All this ran seamlessly with no hitch or errors. pip freeze shows the following installed items:
certifi==2021.5.30
charset-normalizer==2.0.4
docutils==0.17.1
idna==3.2
Kivy==2.0.0
Kivy-Garden==0.1.4
kivymd # file:///Users/robinhahn/PyProg/kvKivyMD/KivyMD
Pillow==8.3.1
Pygments==2.9.0
requests==2.26.0
urllib3==1.26.6
I was following a Codemy video tutorial and noticed that the presenter's pip freeze showed 4 more entries:
chardet==4.0.0
kivy-deps.angle==0.3.0
kivy-deps.glew==0.3.0
kivy-deps.sdl2==0.3.1
Cd'ed into the /demos/kitchen_sink folder, ran 'python3 main.py' which failed, raising this error, the last few lines of the traceback appear to focus on a file called kivytoast.py:
File "main.py", line 144, in <module>
KitchenSinkApp().run()
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/app.py", line 949, in run
self._run_prepare()
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/app.py", line 944, in _run_prepare
self.dispatch('on_start')
File "_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "main.py", line 65, in on_start
Builder.load_file(
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/builder.py", line 306, in load_file
return self.load_string(data, **kwargs)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/builder.py", line 373, in load_string
parser = Parser(content=string, filename=fn)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 402, in __init__
self.parse(content)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 508, in parse
self.execute_directives()
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 472, in execute_directives
mod = __import__(package)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/__init__.py", line 11, in <module>
from .kivytoast import toast
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/__init__.py", line 3, in <module>
from .kivytoast import toast
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/kivytoast.py", line 72, in <module>
class Toast(BaseDialog):
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/kivytoast.py", line 90, in Toast
self, instance_label: Label, texture_size: list[int, int]
TypeError: 'type' object is not subscriptable
Still somewhat of a novice, and not really sure how to proceed from here.
ETA: I brought this up in VSCode and the last word:
list[int, int]
was squiggly-underlined, indicating it's the offending item. I have no idea what 'type' object is not subscriptable means or how to fix it.
Thanks to all who read and ponder this problem.
I'm on the same course right now and just got to that file with the same issue. I followed the path to the 'kivytoast.py' file and changed the following line (line 89):
def label_check_texture_size(self, instance_label: Label, texture_size: list([int, int])) -> NoReturn:
The kivymd devs seemed to have made a mistake and did list[int, int] instead of list([int,int]). You could also just leave it as [int,int] and it would work the same since it is alread in list format. Goodluck with the rest of your course!

Python wrapper install gives "Command "python setup.py egg_info" failed with error code 1"

I've been trying to install this Python wrapper for the past two days. I went through all the other questions here on Stack Overflow. Tried literally everything, and nothing seems to work.
Processing /../../../../../wrappers/Python
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-twPZdY-build/setup.py", line 50, in <module>
**cffi_args
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/local/lib/python2.7/site-packages/setuptools/dist.py", line 319, in __init__
_Distribution.__init__(self, attrs)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/local/lib/python2.7/site-packages/setuptools/dist.py", line 386, in finalize_options
ep.load()(self, ep.name, value)
File "/private/tmp/pip-twPZdY-build/.eggs/cffi-1.10.0-py2.7-macosx-10.11-x86_64.egg/cffi/setuptools_ext.py", line 188, in cffi_modules
add_cffi_module(dist, cffi_module)
File "/private/tmp/pip-twPZdY-build/.eggs/cffi-1.10.0-py2.7-macosx-10.11-x86_64.egg/cffi/setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "/private/tmp/pip-twPZdY-build/.eggs/cffi-1.10.0-py2.7-macosx-10.11-x86_64.egg/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "../ffi_build.py", line 34, in <module>
ffi.set_source('../_ffi', None)
File "/private/tmp/pip-twPZdY-build/.eggs/cffi-1.10.0-py2.7-macosx-10.11-x86_64.egg/cffi/api.py", line 612, in set_source
raise ValueError("'module_name' must not contain '/': use a dotted "
ValueError: 'module_name' must not contain '/': use a dotted name to make a 'package.module' location
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-twPZdY-build/
I've reinstalled everything at least twice, updated, tried sudo -H, but nothing seems to work. It seems like a problem with setuptools, but I have no idea how to fix it.
Mac OSX 10.11.6 (El Capitan)
Python 2.7.13
Pip 9.0.1
After carefully reading through the error message, I managed to find the file called ffi_build.py under the Python folder I was trying to bind. As stated in the error message, at line 34 there was a module naming statement that contained a '/'. By replacing that '/' with a '.' I solved the issue and managed to bind the Python wrapper with no issue whatsoever.

portia (scrapy/slybot) errors on windows

i installed portia and got it to work i annotated some websites (looks really good)
but when i try to run the spiders i get some errors and nothing gets crawled
im running python 2.7.6 on win 7
C:\Python27\Scripts>python portiacrawl C:\portia\slyd\data\projects\new_project
Traceback (most recent call last):
File "portiacrawl", line 7, in <module>
execfile(__file__)
File "C:\portia\slybot\bin\portiacrawl", line 56, in <module>
main()
File "C:\portia\slybot\bin\portiacrawl", line 54, in main
subprocess.call(command_spec)
File "C:\Python27\lib\subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 2] O sistema nÒo conseguiu localizar o ficheiro especificado
I am troubleshooting portia on Windows 8.1 and encountered the same error, exactly.
Try running 'python portiacrawl' by itself to determine if there is a subsequent menu. You should be able to see Help info on 'portiacrawl'. I suspect that you need to name the [spider] & [options] as well as change the terminal directory to see the output from the crawler. I suggest trying the following but rename [spider] to actual name of your spider w/o brackets:
Enter into terminal: C:\portia\slyd\data\projects <------Change to proper directory in cmd
Make sure you are in the terminal directory "C:\portia\slyd\data\projects"
The Cmd propmpt should look like: C:\portia\slyd\data\projects> <----waiting for portia initiation.
Enter into terminal:
python portiacrawl C:\portia\slyd\data\projects\new_project [spider] -t csv -o test.csv; or,
python portiacrawl [spider] -t csv -o test.csv
Report back. I am curious as to the terminal response. Did it initiate portiacrawl & return "access is denied."

why youtube_upload is giving xml.etree.ElementTree.ParseError in python 2.7 on linux

I am new to python and while searching i found that i can upload a video to youtube in command line in linux and i am using centos 5.7
i first installed python 2.7 and face many problems in doing it but i search it on google and find answers
one main problem had faced and solved the httpsconnection and after installing the open ssl and openssl-devel it is ok
i am using this command in order to Upload the video:
>python youtube_upload.py --email="test.for.utube#gmail.com" --password="****" --title="test" --category="test" test.mp4
and getting this result:
Login to Youtube API: email='test.for.utube#gmail.com', password='********' Traceback (most recent call last):
File "youtube_upload.py", line 449, in <module>
sys.exit(catch_exceptions(EXIT_CODES, main_upload, sys.argv[1:]))
File "youtube_upload.py", line 105, in catch_exceptions
fun(*args, **kwargs)
File "youtube_upload.py", line 381, in main_upload
captcha_response=options.captcha_response)
File "youtube_upload.py", line 183, in login
self.categories = self.get_categories()
File "youtube_upload.py", line 255, in get_categories
xml = ElementTree.XML(xmldata)
File "/usr/local/lib/python2.7/xml/etree/ElementTree.py", line 1301, in XML
parser.feed(text)
File "/usr/local/lib/python2.7/xml/etree/ElementTree.py", line 1643, in feed
self._raiseerror(v)
File "/usr/local/lib/python2.7/xml/etree/ElementTree.py", line 1507, in _raiseerror
raise err
xml.etree.ElementTree.ParseError: syntax error: line 1, column 49
and didn't find any solution on google.
so I hope that anyone can help me to successfully complete the youtube upload through the command line.
Thanks at all. and if I can have a fast reply about the time expected to have a solution so i know how much should i wait
I have no idea what youtube_upload.py is, but if you're looking for a "canonical" Python command line script that supports YouTube uploads (and supports OAuth 2 for authorization), try http://code.google.com/p/googlecl/

Aptana update breaks Django debugging

I set up my Aptana Studio 3 / PyDev debugger according to the instructions and even got to the point where everything worked, including breakpoints and auto-reload. Loved it. Now, as of an update last Saturday, the debugger doesn't work any more.
I noticed that the
Aptana Studio 3/plugins/org.python.pydev.debug_x.x/pysrc
folder has gone missing. I found another pysrc folder in
Aptana Studio 3/plugins/org.python.pydev_x.x
which seems to contain the required pydevd module, together with the patch_django_autoreload() function and all. But if I put it on the Python path, I just get an ugly stack trace, ending in
OSError: [Errno 2] No such file or directory
Any ideas what's gone wrong here? Using Aptana Studio 3.2.0.201206251729, Django 1.3.1, Python 2.7.1 on OS X 10.7.4.
EDIT The full traceback:
Executing process on new console: /usr/bin/python /Users/timo/Documents/aptana-studio-3-workspace/ssm/ssd/manage.py runserver 0.0.0.0:8000
Warning: to actually kill the created console, the parent process (in Eclipse console) must be killed first.
Traceback (most recent call last):
File "/Users/timo/Documents/aptana-studio-3-workspace/ssm/ssd/manage.py", line 22, in <module>
execute_manager(settings)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 67, in handle
self.run(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 76, in run
autoreload.main(self.inner_run, args, options)
File "/Applications/Aptana Studio 3/plugins/org.python.pydev_2.6.0.2012062121/pysrc/pydevd.py", line 1175, in main
return original_main(main_func, args, kwargs)
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 138, in main
reloader(main_func, args, kwargs)
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 116, in python_reloader
sys.exit(restart_with_reloader())
File "/Applications/Aptana Studio 3/plugins/org.python.pydev_2.6.0.2012062121/pysrc/pydevd.py", line 1212, in restart_with_reloader
popen = subprocess.Popen(args, env=new_environ)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1202, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
EDIT 2 Some more debug info, as requested:
args: ['xterm', '-e', '/usr/bin/python', '/Users/timo/Documents/aptana-studio-3-workspace/ssm/ssd/manage.py', 'runserver', '0.0.0.0:8000']
new_environ: {'PYTHONIOENCODING': 'UTF-8', 'RUN_MAIN': 'true', 'VERSIONER_PYTHON_PREFER_32_BIT': 'no', 'LOGNAME': 'timo', 'USER': 'timo', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'HOME': '/Users/timo', 'DISPLAY': '/tmp/launch-Hsa1eC/org.x:0', 'SHELL': '/bin/bash', 'TZ': 'Europe/Vienna', 'VERSIONER_PYTHON_VERSION': '2.7', 'SECURITYSESSIONID': '186a5', 'GL_ENABLE_DEBUG_ATTACH': 'YES', 'PYDEV_CONSOLE_ENCODING': 'UTF-8', 'com.apple.java.jvmTask': 'JNI', 'PYTHONPATH': '/Applications/Aptana Studio 3/plugins/org.python.pydev_2.6.0.2012062121/pysrc/pydev_sitecustomize:/Users/timo/Documents/aptana-studio-3-workspace/ssm/ssd:/Applications/Aptana Studio 3/plugins/org.python.pydev_2.6.0.2012062121/pysrc:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC:/Library/Python/2.7/site-packages:/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.4.0.2012020116/pysrc', 'SSH_AUTH_SOCK': '/tmp/launch-ILkkCc/Listeners', 'CELERY_LOADER': 'djcelery.loaders.DjangoLoader', 'Apple_PubSub_Socket_Render': '/tmp/launch-GuOmAI/Render', 'TMPDIR': '/var/folders/yw/7q8d2tzj70q1yqwwqhgkqsw00000gn/T/', 'APP_ICON_844': '../Resources/aptana.icns', 'PYDEV_COMPLETER_PYTHONPATH': '/Applications/Aptana Studio 3/plugins/org.python.pydev_2.6.0.2012062121/pysrc', '__CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'Apple_Ubiquity_Message': '/tmp/launch-lxY2Pu/Apple_Ubiquity_Message', 'DJANGO_SETTINGS_MODULE': 'ssd.settings', 'COMMAND_MODE': 'unix2003'}
There's two things to note here. 1) I tried to check whether everything on the PYTHONPATH actually existed. This was mostly the case, except for /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip and /Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.4.0.2012020116/pysrc, which makes me wonder whether I just have to get Aptana to rescan the Python directories.
2) The Aptana application path contains spaces (by default). I've seen some rare cases where libraries of any kind still choke on that.
The org.python.pydev.debug/pysrc is really removed (and the correct one is really org.python.pydev/pysrc as you found out)... Will update the homepage to reflect that :)
So, with this it should be working... Now, as for your error, please post the complete error log (with just that part, it's hard to know what may be happening -- tested it here with that path and it does work properly).
not sure if related but I upgraded eclipse from 3.6 to 4.2 and Aptana from 2 to 3 with pydev
Now my debugger is not working. After upgrading eclipse, aptana, pydev, Debugger not working
I had this issue too and just upgraded to PyDev 3.4.1, which fixed things for me. Read through http://pydev.org/manual_adv_debug_console.html if you keep having issues.