简体   繁体   中英

python3.7 install on mac not recognized in terminal

I installed python3.7 using:

brew install python@3.7

Then I did:

echo 'export PATH="/usr/local/opt/python@3.7/bin:$PATH"' >> /Users/sony/.bash_profile
export LDFLAGS="-L/usr/local/opt/python@3.7/lib"

When I do:

/usr/local/opt/python@3.7/bin/python3

I get:

Python 3.7.10 (default, Apr 27 2021, 08:48:55)

Which means it works but when I do:

python3.7 

I get:

-bash: python3.7: command not found

Not sure what I missed here?

There are a few things that you could try:

  • Make sure your path is correct and properly connected
  • Go to users>your_user then click on Cmd+shift+. this way you will be able to access the hidden files, then proceed to open the .bash_profile and make sure the export path is properly entered/or enter it and save. (remember to refresh the terminal before running the python command)
  • Try typing just python3 in the terminal, the terminal should automatically recognize which version of python you are working on.
  • You could add your export path to .zshrc file and shift to the zsh terminal by entering chsh -s /bin/zsh

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