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
Related
I have a telegram bot written using python-telegram-bot that was working fine but after a few weeks, when I start the script, it seems like it cannot find some libraries & modules.
As an example, "Update" is widely used in my code and it was working just fine. But now it cannot be found by python.
Here are some of my imports.
from telegram import Update, ForceReply, InlineQueryResultArticle, InputTextMessageContent, ReplyKeyboardRemove, InlineKeyboardButton, InlineKeyboardMarkup, Update, User, ReplyKeyboardMarkup, Contact, Message, KeyboardButton
And here is the error.
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
NameError: name 'Update' is not defined
Does anyone know any solution?
I tried moving to a new environment, reinstalling python-telegram-bot with --pre or --upgrade switches, clearing the python cache and reloading the vs code ssh window.
I don't think there is a good way to transfer environments to production (Correct me if I am wrong), however, you can build a new environment using the exact same packages that are installed in your environment using:
pip freeze > requirements.txt
This saves every package you used in the development env in a file.
Then you can use this file in a docker file to build the exact same dependencies your bot was developed with, using:
pip install -r requirements.txt
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).
I just downloaded Pycharm because Spyder on Anaconda wasn't working anymore on my Mac. I am trying use Tkinter and have tried to run code using both
from tkinter import *
and
import tkinter as tk
The second is from my python class. Both times it returns
ImportError: No module named tkinter
I have tried to search for "tkinter" on Python Interpreter but there's no solid "tkinter." Only others like tkinter.math. Please help.
Tkinter would not be visible on Python Interpreter since it is a part of standard Python installation, the only additional modules or packages which user downloads are visible in Settings. Since, Spyder on your PC is not working as well, make sure python is installed properly and is configured correctly with path details properly set up.
I think you should check the interpreter of PyCharm.
Or Reinstall the python package and make a virtual environment.
I have built a GUI using PyQt5 and wanted to distribute it to other computers without Python installed by packageing it with pynsist. Unfortunately, when launching the shortcuts produced by the installer, the GUI does not open as expected and Python keeps crashing (even if Python is instlalled).
The console shows the following error upon crashing:
ModuleNotFoundError: No module named 'sip'.
This is due to from PyQt5.QtCore import *.
Unfortunately, when launching the .launch.py script on a computer with Python installed, everything works fine. I suppose this is because it then targets the installed version instead of the version included in the build of the GUI.
However, the shortcuts do not work, no matter if Python is installed, giving me the above error.
Any ideas how to fix this problem and make the shortcuts work on computers that do not have Python installed?
Thank you in advance!
When I first encountered this problem I simply added sip.pyd to my project-folder. You can find it under:
x:/path-to-python/Lib/site-packages/sip.pyd
but what realy solved my problem was using pyinstaller.
It automatically detects most dependencies and most of the time runs without complicated configurations.
pip install pyinstaller
pyinstaller main.py
# done
Sip is a separate package which PyQt5 requires. You can include it with your application by listing it in pypi_wheels=, as in the PyQt5 example:
[Include]
packages=listapp
pypi_wheels= PyQt5==5.6
sip==4.18
If you're using the latest version of PyQt5 (5.10.1), then the latest version of sip (4.19.8) should work with it.
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