I have an application that displays images, using QtGui.QImage. To save space, I changed the GeoTiff compression from LZW to JPEG, but now I get the following error:
foo: JPEG compression support is not configured.
foo: Sorry, requested compression method is not configured.
I have not found anything how I can configure PyQt to understand that type of compression. Do I need a specific build or can I set it somewhere?
Using Python 3.10 with PyQt5.15
Thanks to the comment of #musicamante, the issue could be solved simply by using:
from PIL.ImageQt import ImageQt
my_q_image = ImageQt(image_path)
Then, my_q_image acts exactly like a QImage.
Important reminder though, which I found while investigating this: PyQt5 support from PIL ends in July 2023!
I want to run a python script in my flutter app. Thanks to starflut package which helped to do this. Now I want to run a python script that uses NumPy and OpenCV libraries. I want to import these libraries into my python script. I researched a lot about how can I achieve this I couldn't find a way. So I'm posting here so that whoever got the solution for this problem can suggest to me how to do this.
I built a code to generate and play random musical notes. It is working great within python, but I would like to make it into an .exe stand alone program, so people without python can use it. I show an image below of the output. It creates a matplotlib figure with a 'TkAgg' backend. There are 5 buttons and an user entry box that all work.
I used cx_freeze to try to package it, and I worked through all of the errors. I also got some of the examples to work. I can see the the build folder is getting the 4 Images and many .wav files I need to draw the musical staff and play the notes. One error showed that the .exe tried to run my code, because it couldn't find the .wav files). I changed how I specified where they were for the .exe. But now when I run the .exe nothing happens.
Unfortunately my code is a monstrosity. It's messy, and somewhat long (750 lines if you count white space). The .py file I am trying to write to the .exe is Interval_Trainer_v1_1.py. It can be found here.
Because it works in python, but not in the .exe, I thought it might have to do with my ignorance of how to use classes in conjunction with plotting well. Basically I call the class, and then initialize a bunch of things so I can refer to them later. That allows me to delete notes I've plotted before, old answers, etc.
How can I practice building up 'TkAgg' backended figures that will execute properly after cf_freeze? I feel like I need to start with some basic ideas and build up to my application, which is fairly complex.
One note, I do use pygame for the sounds.
Here is my setup file:
from cx_Freeze import setup, Executable
import os
os.environ['TCL_LIBRARY']=r'C:\Users\Bart\Anaconda3\tcl\tcl8.6'
os.environ['TK_LIBRARY']=r'C:\Users\Bart\Anaconda3\tcl\tk8.6'
import sys
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
additional_mods = ['numpy.core._methods', 'numpy.lib.format',"matplotlib.backends.backend_tkagg", 'matplotlib.pyplot', 'matplotlib.image', 'matplotlib.widgets']
setup(
name = "Interval Trainer",
version = "1.0.0",
author = "Bart",
author_email = "bcubrich#gmail.com",
options = {"build_exe": {'includes': additional_mods,"packages":["pygame","tkinter",'random'],
"include_files": [
'Images/F cleff 8vb.png', 'Images/F cleff.png',
'Images/G cleff 8vb.png', 'Images/G cleff.png',
'Pitches/A#1.wav', 'Pitches/A#2.wav', 'Pitches/A#3.wav',
'Pitches/A#4.wav', 'Pitches/A#5.wav', 'Pitches/A1.wav',
'Pitches/A2.wav', 'Pitches/A3.wav', 'Pitches/A4.wav',
'Pitches/A5.wav', 'Pitches/Ab1.wav', 'Pitches/Ab2.wav',
'Pitches/Ab3.wav', 'Pitches/Ab4.wav', 'Pitches/B#2.wav',
'Pitches/B#3.wav', 'Pitches/B#4.wav', 'Pitches/B1.wav',
'Pitches/B2.wav', 'Pitches/B3.wav', 'Pitches/B4.wav',
'Pitches/B5.wav', 'Pitches/Bb1.wav', 'Pitches/Bb2.wav',
'Pitches/Bb3.wav', 'Pitches/Bb4.wav', 'Pitches/C#2.wav',
'Pitches/C#3.wav', 'Pitches/C#4.wav', 'Pitches/C#5.wav',
'Pitches/C2.wav', 'Pitches/C3.wav', 'Pitches/C4.wav',
'Pitches/C5.wav', 'Pitches/C6.wav', 'Pitches/D#2.wav',
'Pitches/D#3.wav', 'Pitches/D#4.wav', 'Pitches/D#5.wav',
'Pitches/D2.wav', 'Pitches/D3.wav', 'Pitches/D4.wav',
'Pitches/D5.wav', 'Pitches/Db1.wav', 'Pitches/Db2.wav',
'Pitches/Db3.wav', 'Pitches/Db4.wav', 'Pitches/E#2.wav',
'Pitches/E#3.wav', 'Pitches/E#4.wav', 'Pitches/E1.wav',
'Pitches/E2.wav', 'Pitches/E3.wav', 'Pitches/E4.wav',
'Pitches/E5.wav', 'Pitches/Eb2.wav', 'Pitches/Eb3.wav',
'Pitches/Eb4.wav', 'Pitches/F#1.wav', 'Pitches/F#2.wav',
'Pitches/F#3.wav', 'Pitches/F#4.wav', 'Pitches/F#5.wav',
'Pitches/F1.wav', 'Pitches/F2.wav', 'Pitches/F3.wav',
'Pitches/F4.wav', 'Pitches/F5.wav', 'Pitches/G#1.wav',
'Pitches/G#2.wav', 'Pitches/G#3.wav', 'Pitches/G#4.wav',
'Pitches/G#5.wav', 'Pitches/G1.wav', 'Pitches/G2.wav',
'Pitches/G3.wav', 'Pitches/G4.wav', 'Pitches/G5.wav',
'Pitches/Gb1.wav', 'Pitches/Gb2.wav', 'Pitches/Gb3.wav',
'Pitches/Gb4.wav']}},
executables = [Executable("Interval_trainer_v1_1.py", base=base)],
)
Output Image
Any help is appreciate.
See the matplotlib user interfaces examples embedding_in_tk and embedding_in_tk2 to practice building up TkAgg backended figures.
I would like to use processing sound library:
import processing.sound.*;
But I have the following error:
No library found for processing.sound
Libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder.
How can I install the sound library? I tried to add it via Sketch > Import library... but I can't find it.
I'm using Processing 2.2.1 on MacOS 10.9.5
Any idea?
This library is available for Processing 3.0+.
To install it, type exactly processing.sound in library installer. Then you'll find it.
I suggest you use minim, which is a very popular sound library for processing.
You can find and use the libary here: http://code.compartmental.net/tools/minim/
If you are using Processing you should already have Minim.
Go to Sketch -> Import Library -> minim
If you still don't find it, Try Go to Sketch -> Import Library -> Add Library -> Minim
You can import the library like this:
import ddf.minim.*;
I'm not sure I understand how these work (I'm not even sure if I should talk about these or this). I was reading pyqtgraph examples and found a call to a "GraphicsObject". Looked it up in pyqtgraph's documentation and it seems like they have their own QGraphicsObject class. Is that correct?
I can't manage to import the correct GraphicsObject (amongst others, like GraphicsItem and such; just using that class as an attempt to explain myself better). I've reinstalled the library so it has nothing to do with it, so... what I'm missing? I apologize in advance if the question is silly.
Example:
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
g = pg.GraphItem()
Error displayed about GraphItem in PyCharm:
Cannot find reference 'GraphItem' in 'init.py'
The inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
*I found what was causing me the trouble. It looks like scipy didn't install correctly although it didn't give me back an error, so I just had to install it in a different way.