Python - Reportlab: Error using custom font - python

Im using the reportlab framework for creating pdf's. I'm also using a custom font in my pdf's called '3of9'. Now, sometimes I'm getting the following error:
IOError: Cannot open resource "/usr/lib/python2.6/site-packages/reportlab/fonts/LeERC___.AFM", while looking for faceName='3of9'
This doesn't happens everytime, but too often. And in most of the cases everything works well, so I have no idea why the error comes up.
Has anyone an idea how to solve this?

either make sure you have LeERC___.AFM at the given path or try to upgrade to a more recent reportlab version.
LeERC___.AFM is part of the reportlab distribution to version 2.1 (which can be downloaded at
http://www.reportlab.com/ftp/ReportLab_2_1.zip)

Related

Opening fits files with no SIMPLE keyword in python

I have a large number of fits files that I'm unable to open becuase of a missing SIMPLE keyword. When I try to open them using astropy's fits.open() it gives the following error:
OSError: No SIMPLE card found, this file does not appear to be a valid FITS file
I tried adding the ignore_missing_simple=True option to fits.open(), but this still gives an error:
OSError: Empty or corrupt FITS file
I'm not sure what to do here. My first thought was to edit the fits header to add a SIMPLE keyword, but if I can't open the file I don't know how to deal with this. I'm wondering if theres more going on than just the missing SIMPLE keyword given the second error.
If it matters, I've downloaded the fits files, I did not generate them myself.
We traced the problem to astropy.io.fits version 4.3
Files generated with version 4.2 can be read with 4.0 or 4.2 but this error pops up with 4.3.1. You could try again after downgrading astropy.io.fits.
Which version of astropy are you using? The problem occurs on 4.3, but it works just fine in 4.2.
This GitHub issue reports the problem in the astropy repository.
I propose you downgrade until the issue is fixed.

xkbcommon: ERROR: failed to add default include path

Whenever I start a python script that tries to access the keyboard, for example, with OpenCV's waitKey() method, I get the following error:
Qt: Failed to create XKB context!
Use QT_XKB_CONFIG_ROOT environmental variable to provide an additional search path, add ':' as separator to provide several search paths and/or make sure that XKB configuration data directory contains recent enough contents, to update please see http://cgit.freedesktop.org/xkeyboard-config/ .
This error started to appear when I installed the keyboard library (or pynput, I am not quite sure) and persisted after I uninstalled them. I do not have QT installed.
Also, neither OpenCV's waitKey nor the two installed libraries can detect any key events (I suspect this is connected), which was already the case before I got the error though.
I am running on Ubuntu 18.04.
How can I go about this problem?
I think this recent issue was resolved here:
https://github.com/conda-forge/qt-feedstock/issues/104
I think the solution is
export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb
but I'm not an expert... somebody back me up here please.

libpython3.6m.dylib vs libpython3.6.dylib

I'm working on creating an app from Python code using py2app.
Everything goes well until I run setup.py, then at the very end of it running I get this message: "ValueError:
'/Users/(my_computer_name)/anaconda3/lib/libpython3.6.dylib' does not exist"
It turns out there is a file there, just named slightly different: It asks for 'libpython3.6.dylib' and there is a file named 'libpython3.6m.dylib'
Any insight would be greatly appreciated, thank you!
Anaconda Python binaries are build with multithread support and that means the library generated will have the form *m.dylib ( see this Google Groups link )
You could create a symlink and try to build using py2app (I had issues with that).
Alternatively this worked for me: I had an equivalent virtualenv setup (which uses a Python Framework and makes py2app locate the library differently) and was able to build the application on that one.

Got a weird error with cx_Freeze compiled Python & Pygame Document as a .exe file

I'm creating a video game with Python 2.7 and Pygame 1.9. I compiled it with cx_Freeze 4.3.4. When I run the .exe file, I get this error:
Fatal Python error: (pygame parachute) Segmentation Fault
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I've looked around the web and around this site but haven't found anything that can really help me. I'm using the default pygame font. So fonts cant be it.
If this helps, I made it in 32 bit format. You can find the source code below.
The Python Source Code can be found here.
All of the Assets can be found here.
Thanks for your time, OrionDark7.
I just figured it out, indeed, it was the font. Instead of:
pygame.font.Font(None, 1)
It should be:
pygame.font.Font("Font Filepath and Filename here", 1)
Sorry if I wasted your time. Was just trying to figure it out.

OpenCV python module build error

I'm trying to build opencv 3 from source(I'm using VS 2013 and compiling for 32bit) so that I can play with feature detection stuff in OPENCV_EXTRA_MODULES with python. My python version is 2.7.5. Everything builds fine except pyopencv_generated. Here's the error log from visual studio. I'm getting vector_Rect2d and boundingBox undeclared identifier errors. VS reports 23 errors in total. All of them can be seen in the screenshot.
Here's the relevant CMAKE screenshot.
Everything else seems to be working OK except this and this is the part that I need unfortunately. Any suggestions? What should I do?
Thanks to berak's comment I was able to fix the issue. It appears that there is some kind of discrepancy between contrib part of the opencv and the installation file provided by opencv. Python enabled build always fails when both of them combined. So I pulled opencv from github rather than using the provided download file.
In short if you are having trouble, pull everything from github rather than using the opencv_download.exe from the opencv.org

Categories

Resources