SystemExit: 1 Error on using kivy - python-3.x

I have the kivy version 1.10.0 and python version 3.6.1. When I am running the very first example from https://media.readthedocs.org/pdf/kivy/latest/kivy.pdf I am getting an error.
Here is my code
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()$
This is the error that i am getting.
[CRITICAL] [App ] Unable to get a Window, abort.
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1

I just had the same issue. I was able to fix it by running the following commands:
py -m pip install --upgrade pip wheel setuptools
py -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
py -m pip install kivy.deps.gstreamer
good luck!

It seems like a dependencies problem. Install these dependencies in the project folder and you will probably be fine (I am assuming that you're using W10).
python -m pip install docutils pygments pypiwin32 kivy_deps.sdl2==0.1.22 kivy_deps.glew==0.1.12
python -m pip install kivy_deps.gstreamer==0.1.17

Related

Modules installed globally not found in VS Code Jupyter Notebook

I've installed several Python modules from PyPi globally on Mac OS using pip3. Running pip3 list confirms that they are installed:
user#users-MacBook-Pro SER-neural-net % pip3 list
Package Version
------------------ ---------
appdirs 1.4.4
audioread 3.0.0
...
librosa 0.9.2
numpy 1.23.4
pip 22.3.1
scikit-learn 1.1.3
scipy 1.9.3
sklearn 0.0.post1
sounddevice 0.4.5
soundfile 0.11.0
torch 1.13.0
...
From the integrated terminal in VS Code where I am running the notebook, I have run the following commands to determine which Python interpreter to use:
user#users-MacBook-Pro SER-neural-net % which pip3
/usr/local/bin/pip3
user#users-MacBook-Pro SER-neural-net % which python3
/usr/local/bin/python3
user#users-MacBook-Pro SER-neural-net % python3 --version
Python 3.7.9
I have selected the appropriate interpreter at the top right of Jupyter Notebook view in VS Code:
But the modules confirmed to be installed for this interpreter are not found:
What has gone wrong?
use this:
python3 -m pip install --user (library)
for example:
python3 -m pip install --user pandas

AttributeError: 'module' object has no attribute 'QRcode'

For some reason I get AttributeError.
My code in Genie is:
import qrcode
import cv2
qr = qrcode.QRCode()
text=raw_input("Insert text to generate: ")
qr.add_data(text)
qr.make()
img = qr.make_image(fill_color="#000000", back_color="#ffffff")
img.save('code.png')
img = cv2.imread('code.png')
cv2.imshow('QR Code', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
I want to generate a QR code through python, but I get errors.
I was able to solve this by first upgrading pip, then installing qrcode as described at PyPi (https://pypi.org/project/qrcode/)
upgrade pip
pip install --upgrade pip
use pip to install qrcode from PyPi
pip install qrcode[pil]
Note: I did these two steps in a python virtual environment for python v3.8. Later will try again with 3.11.1 and will try to circle back to this thread if/when I get that working.
I followed these instructions for my python3 virtual env: https://docs.python.org/3/tutorial/venv.html
python3 -m venv tutorial-env

pyttsx3.init() give an error in python 3.9

I tried below code:
>>> import pyttsx3
>>> engine = pyttsx3.init()
>>> engine.say('hello')
>>> engine.runAndWait()
But it give me an error as below:
import pywintypes
ModuleNotFoundError: No module named 'pywintypes'
I already tried this to solve:
pip install pypiwin32
python -m pip install pywin32
pip install -U pypiwin32
python -m pip install pyttsx3==2.71
But not any one work for me.
I'm using win10
can anyone help me?
If you want to use pyttsx3 in python 3 you have to use pip3 not pip to install the packages. It won't work with pip. pip works for python2 only.
Try the following:
pip3 install pywin32 pypiwin32 pyttsx3
This should work

ImportError: No module named PIL works for 3.7, but not 3.8

I have the Pillow module installed as seen on pip list. Which shows Pillow 7.2.0.
I have code which works on python 3.7.
from PIL import Image, ImageTk
However, when running the same on python 3.8 get the error message.
Exception has occurred: ModuleNotFoundError
No module named 'PIL'
I note there is supposed to be a working solution here:
stack link with potential solutions
2 solutions are:
import Image
uninstall Pillow and re-install
However, the above suggestions do not work.
How do i get Image and ImageTK working (on version 3.8) please ?
You could start a virtual environment venv or virtualenv with clean python3.8 and install modules there or try with:
python-3.8 -m pip install Pillow
or
python3.8 -m pip install Pillow
Edit:
In the end it worked with:
py -3.8 -m pip install Pillow
Hope this was useful ;)

Use RPi.GPIO with Python 3.6

I try to use RPi.GPIO with Python 3.6.
I installed RPi.GPIO and it's working with Python 3.4, but not with Python 3.6
I get this Error:
ModuleNotFoundError: No module named 'RPi'
I immport the module in my script like this:
import RPi.GPIO as GPIO
Add this line to the top of your *.py file:
#!/usr/bin/env python3.6
Run these commands in your shell:
sudo python3.6 -m pip install --upgrade pip setuptools wheel
sudo python3.6 -m pip install RPi.GPIO
This should fix the Problem.
By this you will install RPi.GPIO for the right python version. In this case 3.6.x.

Resources