0

I just installed Python 3.8.5 with the executable from the Python website (I am using Windows). Then, when running python3 example.py, which uses tkinter, it returns

Traceback (most recent call last):
  File "example.py", line 3, in <module>
    import tkinter
ModuleNotFoundError: No module named 'tkinter'

When I run python3 --version in Command Prompt, though, it outputs Python 3.8.0b1. Also, when I type something invalid after python or python3, like python foo, it outputs C:\Users\User\Downloads\depot_tools\bootstrap-3_8_0b1_chromium_1_bin\python\bin\python.exe: can't open file 'foo': [Errno 2] No such file or directory. I assume all this must be happening because it is using the Python install from the Chromium depot_tools, which I must have installed at some point.

I have removed C:\Users\User\Downloads\depot_tools from both the User and System environment variables and added C:\Users\User\AppData\Local\Programs\Python\Python38-32\ to both, to no success. Deleting the depot_tools folder also doesn't work, outputting nothing when running python or python3. I know there is nothing wrong with the Python 3.8.5 install because running C:\Users\User\AppData\Local\Programs\Python\Python38-32\python.exe example.py runs the program as intended.

How do I change the environment variables to make running python or python3 use my Python 3.8.5 install?

DRESphAl
  • 11
  • 1
  • 5
  • On Windows, you can change the default that the `py` command will pick by setting the environment variable `PY_PYTHON` to the version you want. – martineau Aug 17 '20 at 23:42
  • @martineau This worked great. If you put this as an answer I will gladly accept it. – DRESphAl Aug 18 '20 at 01:12
  • Too late now, but thanks for the offer. It's in the documentation for [Using Python on Windows](https://docs.python.org/3/using/windows.html?highlight=py_python#using-python-on-windows) in the [Customizing default Python versions](https://docs.python.org/3/using/windows.html?highlight=py_python#customizing-default-python-versions) section. – martineau Aug 18 '20 at 06:06

0 Answers0