Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Can't find module tkinter after exporting code from Jupyter

Writer Matthew Barrera

I exported a file from Jupyter to a .py format. The code works fine on Jupyter itself, but when I try to run it directly from the command line I get the following error

Traceback (most recent call last): File "/usr/lib/python3.5/tkinter/__init__.py", line 36, in <module> import _tkinter
ImportError: No module named '_tkinter'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "analysis.py", line 30, in <module> import matplotlib.pyplot as plt # NOTE: This was tested with matplotlib v. 2.1.0 File "/usr/local/lib/python3.5/dist-packages/matplotlib/pyplot.py", line 2374, in <module> switch_backend(rcParams["backend"]) File "/usr/local/lib/python3.5/dist-packages/matplotlib/pyplot.py", line 207, in switch_backend backend_mod = importlib.import_module(backend_name) File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/usr/local/lib/python3.5/dist-packages/matplotlib/backends/backend_tkagg.py", line 1, in <module> from . import _backend_tk File "/usr/local/lib/python3.5/dist-packages/matplotlib/backends/_backend_tk.py", line 5, in <module> import tkinter as Tk File "/usr/lib/python3.5/tkinter/__init__.py", line 38, in <module> raise ImportError(str(msg) + ', please install the python3-tk package')

Both python-tk and python3-tk are installed. I'm using Python 3.5.2 in my Jupyter code. I've seen this thread and many others about this problem, but I still can't figure it out. What puzzles me the most is that the code does run on Jupyter, but I can't run it on a terminal when I export it.

Could someone please point me in the right direction as to solve this issue? Thank you in advance.

2 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy