简体   繁体   中英

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?

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

echo $PATH

on the commandline.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM