Been trying for days to figure out why this won't work. I've tried this on 3 different freshly new Linux Mint distros and I get this error every time.
I'm trying to complete step 1 for the GUI tutorial on rasperry pi's website. https://www.raspberrypi.org/learning/getting-started-with-guis/
I've simply done the following:
Verified Python3 is installed and up to date
Installed guizero
from guizero import App
app = App(title="Hello world")
app.display()
The error message follows attempting to run this file. (Title is complete error message)
Edit:
Yes, I am using Python 3. I verified Python 3 is installed and run the script using Python 3. I installed guizero via pip3.
Tkinter only comes as standard on windows. The default GUI module for Linux is Gtk. Tkinter is available on apt under the name Python-Tk
python3:
sudo apt-get install python3-tk
Related
So I have made a App using Tkinter and compiled it, everything works fine on my end. However when I sent it to a friend the tkinker app itself ran fine (ie. the gui ran and responded) BUT certain parts didn't work.
So part of the app allows you to ping an ip and that works fine and updates the tkinter Listbox. What doesn't work is running the discord bot and network sniffing using the scapy module.
Now that's most likely because he doesn't have them modules and I can make the app check for them and download them but what I can't figure out is how to check and install pip through the tkinter app as he doesn't even have pip installed. How would I do this the only way I know how to install modules is through pip
SUMMORY QUESTION:
so how do I check and install pip if missing on a tkinter app
After hours of trial an error, I hope, somebody can help me here.
I got my MacBook Air (M1, 2020) and want to use kivy for python-programming on it.
When I first bought the Laptop 3 month ago it took a lot of work to find a way to run kivy/ execute my kivy-code on it.
Finally, I ended up with the Kivy.app version which created [please excuse my limited understanding...] a Application, I could drag my python-files on or execute the files via the command line like kivy main.py. The "usual" way of simply installing kivy via pipdid never work (as far as I understood because the presented wheel is not compatible with the M1-Chip).
Now, I upgraded my MacOS to Monterey, which crashed everything. I can't even give a lot of information about what's broken. when I try to drag files on the Kivy-Application simply nothing happens. Executing any file (even a simple print("Hello")via the command line (like kivy main.py) results in
kivy
/Applications/Kivy.app/Contents/Resources/venv/bin /Applications/Kivy.app/Contents/Resources
/Applications/Kivy.app/Contents/Resources ImportError: No module named site
Since I don't use any special setup, just the fresh updated MacOS in it's newest version and python (installed via homebrew and already reinstalled after updating the OS) I hope anyone with more understanding of the how's and why's than me already fixed this problem for him/her self and can enlighten me.
I could run kivy on MacOS with M1 chip using rosetta 2.
Install rosetta 2
softwareupdate --install-rosetta
Start a terminal with rosetta. Right click to /Applications/iTerm or /Applicatins/Utilities/Terminal > Get Info > Open Using Rosetta
Create a fresh virtualenv. Install requirements
pip install kivy[base] kivy-examples
Run main.py (python main.py)
main.py
import kivy
kivy.require('2.0.0')
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()
Do you have Rosetta2 installed? I ask because Kivy.app is an Intel Application and cannot work without that.
Install CLI Kivy Tools for Apple M1 Chip Mac
You need Homebrew and XCode, follow this guide:
Dependencies (for macOS); you need one more dependency:
brew install ffmpeg
Install step; see "Development install".
After calling either:
python setup.py build_ext --inplace
...or your "make" command, you can call sudo make install to build Kivy in your Python3 folder and remove the folder you downloaded previously.
If, during the build, you have an error due to missing cython, you need to install cython from the source; you can do this here.
P.S., I don't know how kivy.app works, but I use VSCode + Kivy CLI 2.1.0dev and when I launch the kivy app (with imported module of kivy); it launches with kivy, but when I try to launch the print('hello') program, it only launches from the console (not with kivy).
Running python3 to bring me into python, and then simply running import tkinter results in the following error:
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
However when going into the python shell (not python3), import tkinter works fine as expected. How can I get tkinter to work with Python3?
Please note the following:
I am on MacOS Catalina
I am working with Python 3.7.3 (based off python3 --version)
It looks like my python3 executable is (/usr/bin/python3)
The path for tkinter is /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/tkinter/
I am able to run idle in Terminal, but I can't run idle3
I don't think I am using a virtualenv or pyenv or anything like that
You need a separate Tcl/Tk installation. Try a newer version of the Python3 binary installer from python.org, which bundles Tcl/Tk.
Don't install tkinter through idle. Try idle3. If nothing, install python3-tk using your OS installer. (I have apt. I'm on Debian.). Good luck!
Don't use _ in import _tkinter
Use import tkinter
I am Sure that this will work. If it works then tick my answer.
Fist open Command Prompt and run pip install tkinter
Then open your python project and press Ctrl + S.
Then run your project.
I hope my answer is useful to you.
I have just started learn how to use python so please forgive me if I come off as a beginner. The programming tool that I want to run requires PyGTK 2.7 or higher, and from what I figure the only way to run the pygtk module is to install msys2. I followed all of the steps up to step 7 in the link attached https://pygobject.readthedocs.io/en/latest/getting_started.html 1, and I wasn't able to run the hello.py script they attached, despite successfully installing msys2 and updating the package database and core system packages. I keep getting the same error message when I try to run the code - "ModuleNotFoundError: No module named 'gi'". Afterwards, I tried running the programming tool anyway and I received a similar message "ModuleNotFoundError: No module named 'pygtk'".
PyGTK is deprecated and no longer being maintained. It hasn't been updated since 2011.
PyGObject is what replaced it. You won't be able to install PyGTK using the instructions you referenced.
You can install PyGTK still using:
pacman -S mingw-w64-x86_64-python2-pygtk
Im trying to download this project in python from github
and import it to eclipse ubuntu.
The interpreter of python is 3 and I noticed that after the git clone and running the setup.py, the output is in folder python 2.7 instead of python 3
And when I try to import scapy_http.http I get an exeption (probably the interpreter looking for it inside python 2.7 folder).
When I try to replace the interpreter to python 2.7 I get other exeption on import scapy.all
the import scapy suppose to come before import scapy_http
I installed scapy for python 3: pip3 install scapy-python3
So how can I import the scapy-http project to my eclipse project given the interpreter is python 3?
Thanks.
It should be ok if you did pip3 install scary-python3. It's a bit hard to tell exactly what's going on (please provide error messages, etc.) but I would suggest you try:
sudo python3 setup.py install
If you haven't already. The problem might be that you left off the 3 and thus it was stored in python 2 libraries.