Friday, February 18, 2022

[SOLVED] How can I use Tkinter in a virtual environment?

Issue

I want to use Tkinter in a virtual environment, but I have a problem: Tkinter is not included with the virtual environment.

On this site, I found a solution: adding the environment variable to the \scripts\activate.bat file. I did so, but it wasn't the solution for me.

I get the following while executing an example file:

(learning) c:\Users\jordy\python\learning>python simpleapp_tk.py                                          
Traceback (most recent call last):                                                                                      
  File "simpleapp_tk.py", line 4, in <module>                                                                           
    import Tkinter                                                                                 
ModuleNotFoundError: No module named 'Tkinter'                                                                          

(learning) c:\Users\jordy\python\learning\sources>

What is the solution here? How can I make Tkinter working?


Solution

In python3, use import tkinter instead pf import Tkinter



Answered By - R.yan
Answer Checked By - Mildred Charles (WPSolving Admin)