1

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?

sony
  • 137
  • 2
  • 9
  • 1
    pls, try python or python3. – simpleApp May 04 '21 at 12:26
  • which shell are you using? the default now is zsh which uses .zprofile instead of .bash_profile – beesperester May 04 '21 at 12:28
  • @simpleApp python gives me 2.7 and python3 gives me 3.6 which both were installed before i tried to install 3.7 that is fine. I want them to stay and have 3.7 configured to python3.7 – sony May 04 '21 at 12:31
  • along with .zsh shell changes. an alternative way would be to manage your dependencies through a virtual environment. something to refer [virtual env](https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv) – simpleApp May 04 '21 at 12:42

1 Answers1

1

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