How To Fix Python Not Running .py Files In Terminal / Command Prompt

Manpreet Singh
3 min readJan 13, 2021

One of the most important aspects of programming is running / compiling the actual code. However, there are instances where for some reason our machines won’t run the python files, here are some common issues and ways to fix them in this case, but first, here is the common way a python file is run in the terminal / command prompt:

The beginning part is us distinguishing using Python or Python 3, and the path directory to the Python file. Now that we have the format right, let’s get to trouble shooting.

Python Installation

Sometimes Python maybe the issue, so let’s verify that we have Python installed on our machine, go to your terminal / command prompt and type in “which python”:

Typically, if Python is installed on your machine it will print out the version of Python your using, the same can be done with Python 3:

As long as you can see some form of Python here, you can be assured that Python is installed on your machine, if you aren’t able to see any Python directory, then you may not have Python installed, in that case read this article I made on how to install Python on your PC.

Directory Issue

Since we’re running a Python script from the terminal, we want to make sure the directory is right. Verify that the directory of the Python script is right, or if your changing your working directory from your terminal /…

--

--