cairo

missing dependency after running pyinstaller

missing dependency after running pyinstaller Question: I have a large application that was developed in pycharm IDE. From the IDE it can be debugged and run. The application can also (and is typically) launched from a terminal command line and run that way. I need this application to be an executable, and I can successfully …

Total answers: 1

pyinstaller not integrating a cairo.Context properly

pyinstaller not integrating a cairo.Context properly Question: I’m trying to prepare an executable for delivery using pyinstaller. I’ve installed and run pyinstaller as follows: sudo pip install pyinstaller everything looks good after the install, so I proceed to run the tool on my application sudo pyinstaller App.py –onefile this produces an executable in the ./dist …

Total answers: 1

Faster bit-level data packing

Faster bit-level data packing Question: An 256*64 pixel OLED display connected to Raspberry Pi (Zero W) has 4 bit greyscale pixel data packed into a byte (i.e. two pixels per byte), so 8192 bytes in total. E.g. the bytes 0a 0b 0c 0d (only lower nibble has data) become ab cd Converting these bytes either …

Total answers: 1

get cairosvg working in windows

get cairosvg working in windows Question: Trying to get this code working: import cairosvg import os path = “D:/PyProjects/Bla/Temp” os.chdir(path) cairosvg.svg2pdf(url=’Pic.svg’, write_to=’image.pdf’) but get errors along similar to this post: Traceback (most recent call last): File “D:/work/lean_python/pdf/other.py”, line 2, in <module> import cairosvg File “D:env_python352libsite-packagescairosvg__init__.py”, line 29, in <module> from . import surface File “D:env_python352libsite-packagescairosvgsurface.py”, …

Total answers: 6

Python: OSError: cannot load library libcairo.so.2

Python: OSError: cannot load library libcairo.so.2 Question: I’m having some trouble running a python script on my Windows 7 platform. I’ve installed Python and also cairo, last one using “pip”. I’m running the script using this command: C:Python34>python.exe label/make_label.py and I get the following error message: Traceback (most recent call last): File “label/make_label.py”, line 6, …

Total answers: 6

How can I get the output of a matplotlib plot as an SVG?

How can I get the output of a matplotlib plot as an SVG? Question: I need to take the output of a matplotlib plot and turn it into an SVG path that I can use on a laser cutter. import matplotlib.pyplot as plt import numpy as np x = np.arange(0,100,0.00001) y = x*np.sin(2*pi*x) plt.plot(y) plt.show() …

Total answers: 2

Convert SVG to PNG in Python

Convert SVG to PNG in Python Question: How do I convert an svg to png, in Python? I am storing the svg in an instance of StringIO. Should I use the pyCairo library? How do I write that code? Asked By: ram1 || Source Answers: The answer is “pyrsvg” – a Python binding for librsvg. …

Total answers: 16

How to unit test a Python function that draws PDF graphics?

How to unit test a Python function that draws PDF graphics? Question: I’m writing a CAD application that outputs PDF files using the Cairo graphics library. A lot of the unit testing does not require actually generating the PDF files, such as computing the expected bounding boxes of the objects. However, I want to make …

Total answers: 6