Pythonn 3.8 - Kivy - Exception: SDL2: Unable to load image - python

After compiling Python code - getting the following error message:
Exception: SDL2: Unable to load image
Tried multiple solutions from StackOverflow and other sources with no success
any suggestions?
Code is executing fine in python compiler

The error message "Exception: SDL2: Unable to load image" typically occurs when a Python program is attempting to load an image using the Simple DirectMedia Layer 2 (SDL2) library, but the library is unable to find or load the image file.
There are several potential causes for this error, including:
Incorrect file path: The program may be trying to load an image file from an incorrect or nonexistent file path.
Incorrect file format: The image file may not be in a format that SDL2 can handle.
Missing dependencies: SDL2 may be missing required dependencies, such as other libraries or plugins.
Permission issues: The user running the program may not have sufficient permissions to access the image file or SDL2 library.
To troubleshoot this issue, you can try the following:
Check the file path: Make sure that the file path specified in the program is correct and that the image file exists at that location.
Check the file format: Verify that the image file is in a format that SDL2 can handle. Supported image formats can vary depending on the version of SDL2 that you are using, so make sure to consult the documentation for the appropriate version.
Check dependencies: Ensure that all necessary dependencies for SDL2 are installed and configured correctly.
Check permissions: Check that the user running the program has sufficient permissions to access the image file and SDL2 library. You may need to adjust file or directory permissions or run the program as a user with appropriate privileges.

Related

WindowsError: [Error 126] The specified module could not be found with python3.7.5

I tried to load an external dll with Python3.7 but it failed
My env :
win10 64bit
python 3.75 64bit
My code :
if path_dll is not None:
path_dll += "xxxx.dll"
print(path_dll)
self.pDll = WinDLL(path_dll)
This raises the following error : the specified module could not be found
The same code works on Python3.9.
Why am I getting this error on Python3.7 ?
I already tried change the path to raw, and all other format, but it still failed.
The "WindowsError: [Error 126] The specified module could not be found" error typically indicates that Python is unable to locate a specific module or library that is needed to run your code. This can be caused by a number of factors, such as:
Incorrect module or library name: Make sure that you have spelled the name of the module or library correctly and that it is imported correctly in your code.
Missing module or library: If you are using a module or library that is not part of the Python standard library, make sure that it is installed on your system and is available to Python.
Incorrect module or library path: If you are using a module or library from a specific location on your system, make sure that the path to the module or library is correct.
Permissions issue: Make sure that you have the necessary permissions to access the module or library.
To troubleshoot this error, you may want to try the following:
Double-check the name and spelling of the module or library to make sure that it is imported correctly.
Check to see if the module or library is installed on your system and is available to Python.
Check the path to the module or library to make sure it is correct.
Check the permissions on the module or library to make sure that you have the necessary access.
If you are still having trouble after trying these steps, you may want to try searching online for more specific troubleshooting advice or consider seeking help from other Python users or developers.

SOLVED - Cannot find/load .dll module

When trying to load a .dll file with
os.add_dll_directory("C:\\path\\to\\file")
library = ctypes.windll.LoadLibrary("C:\\path\\to\\file\\tdcbase.dll")
I get following error message:
FileNotFoundError: Could not find module 'C:\path\to\file\tdcbase.dll' (or one of its dependencies).
Try using the full path with constructor syntax.
I'm trying to run it with Python 3.9.7 on Windows11 (on Windows10 it also didn't work).
Using other Python versions (3.6, 3.7 and 3.8) did not change anything either.
Also, I don't think that there are any dependencies whose directory would need to be added.
There is also a 32-bit version of that file (tdbase.dll). When I try to load this with my 64-bit machine, I get following error message:
OSError: [WinError 193] %1 is not a valid Win32 application
So it seems as if it can recognise that it is the wrong bit number, i.e. it can find the file, but in the case of 64-bits not?
Can anyone see where the problem lies?
EDIT: After installing an additional usb driver, which was needed to speak to the connected instrument, the library could be loaded and everything works fine now.

Can't load audio files with librosa

Unless I use one of librosa's native 'example' audio files which are in some format '.ogg', I cannot load audio.
Every github issue and SO answer says I need to install ffmpeg. I found a python package called ffmpeg and installed it into my virtual environment. I also found some sort of multi-purpose program called ffmpeg and installed it onto my Windows machine, and added it's location to my PATH variable.
I still get the same warnings and errors that everyone else is getting:
c:\users\wesle\appdata\local\programs\python\python38\lib\site-packages\librosa\core\audio.py:162: UserWarning: PySoundFile failed. Trying audioread instead.
warnings.warn("PySoundFile failed. Trying audioread instead.")
---------------------------------------------------------------------------
.
.
.
115 # All backends failed!
--> 116 raise NoBackendError()
I can find no resolution for this problem despite the number of people asking for help on it.
I don't know what fileformat you are trying to load, but in most cases installing ffmpeg is the solution to this problem. It is important to add the "../bin/" directory to PATH and restart the environment. Using the "set" command from prompt you can check that the current path contains the folder.

"Cannot read file" error when loading an .svg file with PyQt4

I'm having troubles using a .svg icon for my windows icon. From what I have read this is due to a bad installation of the PyQt4 plugins, but I am confused on how to fix it.
When I try to load the image
self.setWindowIcon(QtGui.QIcon("File-View-front.svg"))
Here is the error message I get:
Cannot read file 'C:/Users/user/PycharmProjects/proj1/File-
View-front.svg', because: (line 2)
I tried printing the supported image formats with
for imageType in QtGui.QImageReader.supportedImageFormats():
print(imageType)
Which outputs:
b'bmp'
b'pbm'
b'pgm'
b'png'
b'ppm'
b'xbm'
b'xpm'
So I am missing formats... If I add the correct plugin path with
QtCore.QCoreApplication.addLibraryPath('C:/ProgramData/Anaconda3/Lib/site-packages/PyQt4/plugins')
(which if I understand correctly I could also do using conf.py, but I could not get that to work either)
I do get every format (including b'svg') using QtGui.QImageReader.supportedImageFormats(), but the error remains.
I am using Anaconda 4.3.1 and I installed PyQt4 with the wheel file I got here.

Building static OpenCV with ffmpeg is still looking for shared libavcodec

I'm trying to build a static OpenCV Python with ffmpeg enabled to run on AWS Lambda. I Need to upload OpenCV my cv2.so in a zip file.
To do so I set the BUILD_SHARED_LIBS=OFF and WITH_FFPMEG=YES. But when doing import cv2 in the Python shell, I get the error:
ImportError: libavcodec.so.53: cannot open shared object file: No such file or directory
If I set WITH_FFPMEG=NO I don't get this error anymore but I need ffmpeg to read a video.
What I would like to do is OpenCV to use the static libavcodec library not the shared one. I thought setting up BUILD_SHARE_LIBS to off would be enough but it's not. T
here are no flags in the cmake file which let you specified the path to libavcodec. I've been looking for sometimes but I can't find a solution.
Any ideas?

Categories

Resources