When I import tinker in python 3.7.3 on Ubuntu 18.04:
>>> import tkinter
I got:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/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'
Then I install tk using both of the following:
sudo apt-get install python3-tk
It didn't work.
I also did all the things in Tkinter module not found on Ubuntu, still didn't work.
I noticed that when I do:
sudo apt-get install python3.7-tk
It says:
Note, selecting 'python3-tk' instead of 'python3.7-tk'
python3-tk is already the newest version (3.6.9-1~18.04).
Is tk automatically installed under python 3.6.9? How can I fix this?
I also saw a solution from https://wiki.python.org/moin/TkInter:
If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C). Do not edit Modules/Setup (it is out of date). You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.
Could someone explain to do how to do the steps mentioned in this paragraph?
OK. I think the problem is that the newest version of tkinter for Ubuntu 18.04 is "python3-tk_3.6.9-1~18.04_i386.deb". Now I found that tk for python3.7.3 is available for other systems(e.g. python3-tk_3.7.3-1_amd64.deb). Can I download and use these ones on my system?
acw1668: Thanks this helped me a lot. I'm using Python 3.8. Using your method was able find where tkinter for Python 3.8 was install (/usr/lib/python3.8/). So i copied the files to (/usr/local/lib/python3.8/) which is where Python is installed on my computer. Now it'e working.
Related
I have this problem when I try to run an app that imports turtle:
Traceback (most recent call last):
File "/home/panos/Documents/python/challenge_60.py", line 1, in <module>
import turtle
File "/usr/local/lib/python3.9/turtle.py", line 107, in <module>
import tkinter as TK
File "/usr/local/lib/python3.9/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I have done the below commands:
sudo apt-get install python3-tk
pip3 install tkinter
pip3 install PythonTurtle
pip3 install Tcl
sudo apt-get install python-tk python3-tk tk-dev
sudo apt-get install python3-PythonTurtle
And, although it is installed, the error still exists. I haven't understand what does wiki says. Could you explain, with all the details, what do I have to do, because I am a newbie at Linux and commands in general?
This error is probably made, because you have installed the tkinter , for instance, on python 3.7, but you are running your code with an interpreter based on python 3.8.
Another reasons, like installing the library in a virtual environment and trying to run the code out of the venv, can also
lead to this error.
Make sure pip and python command are in the same location/path
to make sure they are from the same SDK.
This command indicates where python is installed on your machine:
(Unix Only)
which python
Windows users, use this snippet below to find path of the installed python :
import sys
locate_python = sys.exec_prefix
print(locate_python)
Check the pip location using the which command as well.
which pip
If pip and python are in the same path, you probably won't get the error anymore.
First you have to pay attention to a few things 1- All the packs must be updated and installed If you have downloaded the packs, update them, especially the pip module that is for installation 2- Note that the spelling of the words you use is correct 3 - Maybe the code you write does not support that module, you should also pay attention to this issue 4- Finally, there are some problems in your code. First, to download the Tkinter module, you have to write pip3 install tk or pip install tk. You should not write the word Tkinter yourself. Update the latest version and then try again. If it still does not work, turn on your Windows 10 (if not) and finally the last solution is to change your ide vs code. The best ide for this situation. Is And you can also help to install and import the library of online articles. If you use pycharm, enter the Windows command line and type pip3 install future or pip install future, and then the thinner will be imported for you, and then enter the following command: from future.moves import tkinter and you can find how to install each house in different ideas with a simple search
Currently using Ubuntu 20.04 LTS with python3.8.5.
Its my first time using ubuntu with absolutely no previous knowledge of terminal.SO,would love to have a detailed answer if possible.
Below is terminal output when i try importing tkinter in python3.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/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'
>>>
I have reinstalled python3 and tkinter using sudo apt.But still it shows same error.
When i run the same command in python IDLE it works without any error.
I hope this explains my problem clearly, if any other info. is required pls reply.
I also tried running the command >>>from tkinter import *
I faced the same issue on MacOS. I was using a Python virtual environment. This command worked for me:
brew install python-tk
CentOS 8 + Python 3.9.5
following are what i have doneļ¼
1st:
yum search tkinter
yum install python39-tkinter.x86_64
2nd:
yum install tk-devel
3rd: cd python3.9.5 source folder
make install
it work in my case
since I'm still using python 3.9, this code works for me:
brew install python-tk#3.9
if using brew install python-tk brew will install python-tk#3.10 which is key-only
I had the same issue. Switched from 3.8 to 3.7 and it worked. I'm using PyCharm CE, which makes it easy to switch between interpreters.
Resolved the issue it occurred because the Tkinter was installed for version 3.5 and not for the 3.8 version. For that, I installed the 3.5 version and kept only one version i.e. 3.8, and installed Tkinter again, and it worked!
This is just a workaround to make things work, but the more preferred way is to create a venv and then install the particular versions of python and libraries that are needed.
I am an absolute newbie. I'm trying to make Python GUI for my school project so I decided to use Tkinter. When I try to import Tkinter it throws this message:
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Developer/CommandLineTools/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'
I tried to find a solution online but I couldn't figure it out (mostly didn't understand it).
I read about some problem with directory in setup.py but I don't understand how to fix it. I have tkinter folder in my python3.7 folder.
I don't really understand these steps that I found:
If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C). Do not edit Modules/Setup (it is out of date). You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.
I'm using Mac OS and use Visual Studio Code.
To check your python version, run this on terminal:
$ python --version
Check what python your machine is using. Run:
$ which python
If it's using python from Homebrew, it's probably using Python 2. If you installed python 3 manually, just install tKinter manually.
$ brew install python-tk
To run python 2 manually, run on terminal:
$ python <FILENAME>
If python 3, run:
$ python3 <FILENAME>
https://stackoverflow.com/a/9883299/4678635 will help you.
In summary, you have to reinstall python for your computer bit system.
And below code strategy is also helpful to you.
try:
from Tkinter import * # for Python2
except ImportError:
from tkinter import * # for Python3
Trying to run a script written for Python3.5 on Ubuntu 64 bit.
I'm 99% sure I installed Python3.5 correctly. It lives at /usr/local/bin. But I am getting this error when I try to run my script:
import tkinter as tk # python3
File "/usr/local/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
I've tried many of the workarounds on here, but to no avail.
apt-get install python3-tk
Says it's up to date and
update-python-modules -a
seems to execute fine, so I really don't know why it's not finding tkinter...
Thanks in advance.
UPDATE: I just blew away the VM, so if someone could give me proper steps on installing Python3.5 + tkinter on Ubuntu 64-bit 14.04, that'd be awesome.
Thanks!
I need to run an application written in python. When I try to load it from terminal I get this error:
File "/usr/local/bin/soar", line 3, in <module>
import form.main
File "/usr/local/lib/python2.6/site-packages/form/main.py", line 14, in <module>
from Tkinter import *
File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
I installed python 2.6.6 from the source files. I am really confused!!
How should I install tkinter?
I am running Xubuntu 13.10. You can see the different versions of python already installed in the below:
How can I remove python2.6.6? I tried to remove all files and folders related to python2.6. Now when I run python, it still loads python 2.6.6 I really have no idea what to do!! I tried to follow the instructions here and here to uninstall it but it did not work, that's why I deleted all the files and folders manually.
Type the following in your terminal:
sudo apt-get install python-tk
Install python3-tk package if you need Tkinter functionality in the 3rd version of python.