'Python command on MacOS terminal not working

I am using MacOS 10.8. I uninstalled python 3.2.3 and installed 2.7. But when I type python in the terminal it shows:

-bash: python3: command not found.

if I use /usr/bin/python then python 2.7 runs. How do I fix this?



Solution 1:[1]

Check if /usr/bin/ is in your PATH variable.

echo $PATH

on the commandline.

Solution 2:[2]

This is a common mistake. First save your python file in a folder, and make sure that you have a .py at the end. Then go to terminal, and type in the address without adding users. For example, my .py file is saved in a folder named Python, on my desktop. My python file is called read. It will work:)

python ~/Desktop/Python/read.py

Then click enter in terminal, and your file should execute.

Solution 3:[3]

You might have python3 symlinked to python. If thats the case then just make sure all file names containing python3 in your /usr/bin/ have been deleted.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hugo
Solution 2
Solution 3 Eric James