Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to install tkinter with Pycharm?

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.

like image 364
TheProgramMAN123 Avatar asked Dec 15 '18 21:12

TheProgramMAN123


People also ask

How do I get tkinter from PyCharm?

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.

How can I install tkinter?

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.

Can you pip install tkinter?

Tkinter can be installed using pip.


2 Answers

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 *
like image 87
Mattatat-tat Avatar answered Sep 21 '22 09:09

Mattatat-tat


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.

like image 26
Dinko Pehar Avatar answered Sep 19 '22 09:09

Dinko Pehar