I used sudo apt-get install python3.6-tk
and it works fine. Tkinter works if I open python in terminal, but I cannot get it installed on my Pycharm project. pip install
command says it cannot find Tkinter. I cannot find python-tk in the list of possible installs either.
Is there a way to get Tkinter just standard into every virtualenv when I make a new project in Pycharm?
Edit: on Linux Mint
Edit2: It is a clear problem of Pycharm not getting tkinter guys. If I run my local python file from terminal it works fine. Just that for some reason Pycharm cannot find anything tkinter related.
Download PyCharm Edu or Install EduTools plugin if you have already installed PyCharm Community or Professional. To join the course, go to the My Courses tab on the Welcome Screen, click Start New Course, and select Python GUI with Tkinter in the list.
The simplest method to install Tkinter in a Windows environment is to download and install ActivePython 3.8 from here. Alternatively, you can create and activate a Conda environment with Python 3.7 or greater that is integrated with the latest version of Tkinter.
Tkinter can be installed using pip.
Make sure you use the right import statement for your version of Python.
Python 2.7
from Tkinter import *
For Python 3.x
from tkinter import *
For python 2
use:
sudo apt-get install python-tk
For python 3
use:
sudo apt-get install python3-tk
When you display info about packages it states:
Tkinter - Writing Tk applications with Python2 (or Python 3.x)
But my assumption is that PyCharm created it's own virtualenv for you project, so you are probably using wrong python interpreter in PyCharm.
Open your PyCharm project. Go to File->Settings->Project->Project Interpreter
. At top, you will see what python interpreter is PyCharm using for a current project. If that's not the system one you have, find path to system interpreter and add it to Python Interpreters
in PyCharm.
More details on PyCharm Documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With