Python Forum
Requirements for html5print module
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Requirements for html5print module
#2
Well since my version of ply was greater than 3.4 I modified the requirements.txt file with the following change (click hide/show):
Then added this to the list Language list in setup.py under the 3.4 version of python(click hide/show):
I uninstalled the prior attempt and then installed html5print with 'python setup.py install'. This ran without error.

The outcome of this is that I haven't been able to do the command line version of html5-print nor have I been successful with any of the code examples using the IDE. The only reference to html5print in the /python/scripts folder is a file named the same that has no extension on it. The file in question has the following 4 lines:
#!C:\Python\python.exe
# EASY-INSTALL-SCRIPT: 'html5print==0.1.2','html5-print'
__requires__ = 'html5print==0.1.2'
__import__('pkg_resources').run_script('html5print==0.1.2', 'html5-print')
Each time I attempt to invoke the module in python I get this error:
Error:
cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && C:\Python\python.exe c:\Users\cartken\.vscode\extensions\ms-python.python-2020.2.64397\pythonFiles\ptvsd_launcher.py --default --client --host localhost --port 63492 c:\Users\cartken\Downloads\py\blabel\htmlprinttest.py " Traceback (most recent call last): File "c:\Users\cartken\.vscode\extensions\ms-python.python-2020.2.64397\pythonFiles\ptvsd_launcher.py", line 48, in <module> main(ptvsdArgs) File "c:\Users\cartken\.vscode\extensions\ms-python.python-2020.2.64397\pythonFiles\lib\python\old_ptvsd\ptvsd\__main__.py", line 432, in main run() File "c:\Users\cartken\.vscode\extensions\ms-python.python-2020.2.64397\pythonFiles\lib\python\old_ptvsd\ptvsd\__main__.py", line 316, in run_file runpy.run_path(target, run_name='__main__') File "C:\Python\lib\runpy.py", line 261, in run_path code, fname = _get_code_from_file(run_name, path_name) File "C:\Python\lib\runpy.py", line 236, in _get_code_from_file code = compile(f.read(), fname, 'exec') File "c:\Users\cartken\Downloads\py\blabel\htmlprinttest.py", line 8 @media (-webkit-min-device-pixel-ratio:0) { ^ SyntaxError: invalid syntax
The example code I am using that generated this is as follows:
from html5print import CSSBeautifier
css = '''@media (-webkit-min-device-pixel-ratio:0) {
    h2.collapse { margin: -22px 0 22px 18px;
    }
    ::i-block-chrome, h2.collapse { margin: 0 0 22px 0; } }
    '''
print(CSSBeautifier.beautify(css, 4))
@media (-webkit-min-device-pixel-ratio:0) {
    h2.collapse {
        margin              : -22px 0 22px 18px;
    }
    ::i-block-chrome, h2.collapse {
        margin              : 0 0 22px 0;
    }
}
Now, I'm not sure if this module is just not compatible with Python 3.6 (only tested by creator to 3.4). Or if I'm doing something wrong in testing.



While looking for answers to this I ran across something that I thought might be a more elegant solution using pdfkit. So, I loaded up pdfkit v0.6.1 and did this test code:
import os 
import pdfkit

pdfkit.from_file("C:\Users\cartken\Downloads\py\blabel\pngtest.html", "out.pdf")
os.startfile("out.pdf", "print")
Which gave me the unicode error below:
Error:
File "c:\Users\cartken\Downloads\py\blabel\pdfkitprint.py", line 4 pdfkit.from_file("C:\Users\cartken\Downloads\py\blabel\pngtest.html", "out.pdf") ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Any input that may be helpful for me resolving either issue would be greatly appreciated.

I'm working on Windows 10 with Python 3.6 32bit

(Mar-11-2020, 03:42 PM)KipCarter Wrote: While looking for answers to this I ran across something that I thought might be a more elegant solution using pdfkit. So, I loaded up pdfkit v0.6.1 and did this test code:
import os 
import pdfkit

pdfkit.from_file("C:\Users\cartken\Downloads\py\blabel\pngtest.html", "out.pdf")
os.startfile("out.pdf", "print")
Which gave me the unicode error below:
Error:
File "c:\Users\cartken\Downloads\py\blabel\pdfkitprint.py", line 4 pdfkit.from_file("C:\Users\cartken\Downloads\py\blabel\pngtest.html", "out.pdf") ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Any input that may be helpful for me resolving either issue would be greatly appreciated.

I'm working on Windows 10 with Python 3.6 32-bit

I'm moving the reference above to a thread by itself. I had formatting errors causing the unicode errors. Once corrected another issue popped up, so it really belongs by itself.
Through a cloudy window,
Kip...

“Progress means getting nearer to the place you want to be. And if you have taken a wrong turn, then to go forward does not get you any nearer.
If you are on the wrong road, progress means doing an about-turn and walking back to the right road; and in that case the man who turns back soonest is the most progressive man.” ― C.S. Lewis
Reply


Messages In This Thread
Requirements for html5print module - by KipCarter - Mar-11-2020, 10:24 AM
RE: Requirements for html5print module - by KipCarter - Mar-11-2020, 03:56 PM
RE: Requirements for html5print module - by buran - Mar-11-2020, 04:29 PM
looking for web print module - by KipCarter - Mar-16-2020, 03:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with code / audio is playing randomly, not matching csv requirements Daniel_kcr 2 683 Sep-07-2023, 05:09 PM
Last Post: deanhystad
  when package built, requirements not installed sabuzaki 1 780 Apr-07-2023, 09:01 AM
Last Post: sabuzaki
  What to do when the requirements.txt file does not work Led_Zeppelin 2 6,597 Nov-04-2021, 06:51 PM
Last Post: snippsat
  Examples of Customer requirements ComputerAstronaut 1 1,880 Dec-08-2020, 03:22 AM
Last Post: Larz60+
  requirements file tdwinfre 7 2,852 Nov-06-2020, 06:01 AM
Last Post: tdwinfre
  How to allow user input only if certain requirements are met vininhosts 3 2,407 May-28-2020, 06:15 PM
Last Post: micseydel
  google-auth requirements.txt strange behavior randalpinto 3 3,803 Dec-21-2018, 02:03 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020