Why I can't use tkinter - python

I use Ubuntu. When I try to install tkinter it throws error
ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none)
ERROR: No matching distribution found for tkinter
I saw that this error is beacuse I already have tkinter, but when I try to import it there is another error
ModuleNotFoundError: No module named 'tkinter'
This happens also when I use capital T (Tkinter).

For installing tkinter in Ubuntu I use the command:
sudo apt install python3-tk

Related

how can I install win32con?

I'm trying to use winshell to generate a url shortcut file,
so I did:
pip installed winshell
However on line 30 of the winshell.py file it requires the module win32con : my understanding is that win32con is apart of pywin32, which is already installed.
The specific error I get when trying to import win32con is:
(base) C:\Users\deana>pip install win32con
ERROR: Could not find a version that satisfies the requirement win32con (from versions: none)
ERROR: No matching distribution found for win32con
I've found a few references online and on stack exchange but nothing.
running windows 11.
pip install pywin32
Happy to help.

ModuleNotFoundError: No module named 'psycopg2' (But it is installed)

I've been stuck on a part of a Udemy course. Even the (very helpful) tutor on there has run of ideas. When I try and run my script I get:
ModuleNotFoundError: No module named 'psycopg2'
I've done pip install psycopg2 and pip install psycopg2-2.8.4-cp37-cp37m-win_amd64.whl. Both result in 'requirement already satisfied'. I tried CTRL+SHIFT+P, Select Interpreter, and got the same problem with all of the three options. Only difference is Python3.8.0 gives me a Unable to import 'psycopg2' pylint(import-error) [1,1] error as well.
C:\Python\Database>pip install psycopg2
Requirement already satisfied: psycopg2 in c:\users\jeff\anaconda3\lib\site-packages (2.8.4)
C:\Python\Database>script1.py
Traceback (most recent call last):
File "C:\Python\Database\script1.py", line 1, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
Edit
I still can't figure this out. And now I just got the same problem with Tweepy. ModuleNotFoundError: No module named 'tweepy' after I'd just successfully installed it. And similar error in the problems tab on VSC Unable to import 'tweepy' pylint(import-error) [1,1].
Psycopg project has modified the way they distribute the package. Starting from version 2.8.0, psycopg2 wheel on Pypi is a source distribution. To get the same package you used to install, you have to
pip install psycopg2-binary
Explanations can be found in psycopg-2.7.4 release note:
The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: </docs/install.html#binary-install-from-pypi>.
I guess you need to first install the dependencies.
sudo apt-get install build-dep python-psycopg2
Now run
pip install pyschopg2
I had a similar issue. I solved it by installing psycopg2 using PyCharm UI as follows :
Go to Current interpreter at the bottom of the window
Python Interpreter
Interpreter Settings
Interpreter Settings
Press (+) to add a package
Add package
Type psycopg2 on the search bar and press Install Package at the botton
Install psycopg2

tkinter no module found windows 10

I am trying to run this code
from tkinter import *
master = Tk()
w = Canvas(master, width=40, height=60)
w.pack()
canvas_height=20
canvas_width=200
y = int(canvas_height / 2)
w.create_line(0, y, canvas_width, y )
mainloop()
and I get the error
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'tkinter'
Since tkinter is already present in python, I checked in the C:\Python38\Lib\site-packages to see if tkinter is already present but its not there, also I tried the following
Running python -m tkinter from the command line should open a window
demonstrating a simple Tk interface, letting you know that tkinter is
properly installed on your system, and also showing what version of
Tcl/Tk is installed, so you can read the Tcl/Tk documentation specific
to that version
as mentioned on tkinter — Python interface to Tcl/Tk
I tried to install the tkinter using pip3 install tk , and I got Requirement already satisfied: tk in c:\python38\Lib\site-packages (0.1.0)
But when I run the code again I get the error
ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none) ERROR: No matching distribution found for tkinter
My python version is Python 3.8.0 and pip version is pip 19.3.1
I have referred to this but no success.
Where am I going wrong? Please help
You may not have ticked tkinter during installation.
Download the latest version of python from python.org
Run the installer
Click modify
Select the Tk checkbox (and anything else you want)
And continue through the installation.
Done.

No module named PyQt5.sip

After upgrading to python-pyqt5 5.12-2 I get this error when I try to import from QtWidgets
from PyQt5.QtWidgets import *
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
Any idea on how can I solve this issue?
The reason is a backward incompatible change in PyQt-5.11
In geoptics this fix works on old and new versions:
try:
# new location for sip
# https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11
from PyQt5 import sip
except ImportError:
import sip
As suggested here pyuic5 - ModuleNotFoundError: No module named PyQt5.sip
Try uninstalling and re-installing all PyQt related libraries:
pip uninstall PyQt5
pip uninstall PyQt5-sip
pip uninstall PyQtWebEngine
Then install them again, this will fix:
ModuleNotFoundError: No module named 'PyQt5.sip'
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'
PPS.:If you got problems uninstalling the libraries, go to your Python folder, like C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python<PYTHON-VERSION>\Lib\site-packages and manually delete the PyQt folders, them uninstall everything and install again (Make sure you have the latest Python version and upgraded your pip too)
If you're building sip and PyQt5 from source using make files, make sure to check PyQt5 install docs. In particular,
Note
When building PyQt5 v5.11 or later you must configure SIP to create a
private copy of the sip module using a command line similar to the
following:
python configure.py --sip-module PyQt5.sip
If you already have SIP installed and you just want to build and
install the private copy of the module then add the --no-tools option.
You should add PyQt5.sip to hidden imports; that should solve the issue.
I repaired this problem
This problem occurred when upgrading pyqt5 version 5.15.0
There was no problem when I reverted to the previous version.
I have
python -V: 3.7.4
PYQT5 5.14.1 and PYSIDE 5.14.1 works fine
In addition to the answer provided by Tadeu (https://stackoverflow.com/a/58880976/12455023) I would also suggest checking version of your libraries to make sure that they match.
Use pip show <library_name>
This will help you to make sure that no earlier installation is conflicting with your current installation.
In place of library_name use PyQt5, PyQt5-sip, PyQtWebEngine. If any of them is present in the system, then use pip uninstall <library_name>==<version_number> to remove that library.
Once you made sure that no other versions of these libraries are there, then you can reinstall the preferred version of that library.

No module name _tkinter error while tkinter is installed

When trying to run my python 3 program that uses matplotlib via the command line, I get the following error:
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
The same happens when simply inputting:
>>>import tkinter
Suggested fixes such as installing python3-tk, python3.5-tk or python3.6-tk do not work, the result is:
python3.6-tk is already the newest version (3.6.6-1+xenial1).
and using matplotlib.use('agg') does not work as I need to output figures:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
with pip install tkinter, python-tk or python3-tk the result is :
Could not find a version that satisfies the requirement python3-tk (from versions: )
No matching distribution found for python3-tk
I also tried updating and reinstalling python3 but nothing seems to work (version 3.6.4). Could it be that python-tk is version 3.6.6 and my python 3.6.4?
Is there any other method I can try?

Categories