2

I am fairly new with python, as I am learning on my own I encounter some minimal errors a students would mostly ask their professors but I dont have the luxury to do that right now so I am here. I want to check if Tkinter is installed using command on my Pc BUT I get a syntax error message, can someone help me with that? I typed -> python -m tkinter

--------------------------------
>> python -m tkinter
  File "<stdin>", line 1
    python -m tkinter
                    ^
SyntaxError: invalid syntax
DYZ
  • 55,249
  • 10
  • 64
  • 93
DragonFly
  • 23
  • 3
  • We (at least not I) are not professors. SO does not aim to tutor languages - you should look for tutorials: https://docs.python.org/3/tutorial/ – Patrick Artner Jan 03 '19 at 17:20
  • 1
    thats because you are trying to run the command as a python code, just type the command in the console without starting python – Mntfr Jan 03 '19 at 17:22

2 Answers2

0

If you want to have a quick one-liner, you can run the following from any command line:

python -c "import tkinter"

It will either output an error if it doesn't exist, or nothing if the module exists. For example, I can see this:

$ python -c "import tkinter"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named tkinter
$ python -c "import array"
$
Michael Pratt
  • 3,438
  • 1
  • 17
  • 31
0

That command is for shell enviroment.

Inside python interpreter you can check it by

import tkinter
Danyla Hulchuk
  • 411
  • 3
  • 6