0

I was trying to run a program that I have been making and ran into a problem with tkinter not being installed, as when I try to run my script in pycharm I get this error: ImportError: No module named '_tkinter', pleaseinstall the python3-tk package`

So I searched on here and found a solution and entered these commands:

sudo apt-get install python-support
sudo update-python-modules -a

which didn't work so I tried:

sudo apt-get install python3-tk

which was tagged as the answer on this question but it threw this error at me:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

Being pretty new to linux and the terminal, I am completely clueless as to how to do this.

I am using python 3.5 and just want to install tkinter so I can run this script, also before anyone asks yes I have imported tkinter and not Tkinter.

2 Answers2

2

sudo apt-get install python3-tk is the correct way to install tkinter for Python 3 on Linux. However, you interrupted apt while it was installing. To fix the errors, run the command the error message suggested and then install tkinter.

sudo dpkg --configure -a
sudo apt-get install python3-tk

Then you can add from tkinter import *, import tkinter as tk or import tkinter to the beginning of your program depending on how you want to use it. You may also be interested in installing idle-python3.4.

Next time you need to install something just open the software manager from Menu, search for the program and install it :-)

aq2
  • 299
  • 3
  • 4
-1

Well when all logic fails- panic. Look for the illogical. I found that I was not running Python 3. My text editor is Geany, and reverts everything to run its default, which was set at Python 2. That included #!.

So, change the defaults in Geany:

Build > Set build commands > then in the dialogs replace every instance of Python with Python3