Python Forum
Installing Python3 on MacOS using brew - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Installing Python3 on MacOS using brew (/thread-33790.html)



Installing Python3 on MacOS using brew - zazas321 - May-27-2021

Hello, I am trying to install python3
I have followed this guide: https://programwithus.com/learn/python/install-python3-mac

After using the following command:
brew install python3
The result is as following:
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/[email protected]/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.9/site-packages

tkinter is no longer included with this formula, but it is available separately:
  brew install [email protected]

See: https://docs.brew.sh/Homebrew-and-Python
Lukass-Air:~ Lukas$ 
Lukass-Air:~ Lukas$ python --version
-bash: /usr/local/bin/python: No such file or directory
Lukass-Air:~ Lukas$ python3 --version
-bash: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3: No such file or directory
Lukass-Air:~ Lukas$ pip3 install requests
-bash: /Library/Frameworks/Python.framework/Versions/3.9/bin/pip3: No such file or directory
Lukass-Air:~ Lukas$ 
As you can see from the command output, it says that python3 has been installed as /usr/local/bin/python3 . However, I am not able to reach python from the terminal. I try with commands:

python --version
-bash: /usr/local/bin/python: No such file or directory
and
python3 --version
-bash: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3: No such file or directory
Also, I have tried to install requests python module using following command:

pip3 install requests
but failed with the following result
-bash: /Library/Frameworks/Python.framework/Versions/3.9/bin/pip3: No such file or directory
Can someone help me understand what is wrong and how do I setup PATHS correctly?


RE: Installing Python3 on MacOS using brew - zazas321 - May-27-2021

I have managed to move forward with my issue by following the suggestions in this post:
https://stackoverflow.com/questions/36001966/unable-to-run-python-3-after-homebrew-installation


Now I am able to get the information by calling python --version and python3 --version.


I have installed latest python3 ( 3.9.5 I believe), but python3 --version returns 3.8.2 for some reason. Why is that?


Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/[email protected]/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.9/site-packages

tkinter is no longer included with this formula, but it is available separately:
  brew install [email protected]

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
🍺  /usr/local/Cellar/[email protected]/3.9.5: 3,078 files, 54.5MB
Lukass-Air:~ Lukas$ python3 --version
Python 3.8.2
Lukass-Air:~ Lukas$ 



RE: Installing Python3 on MacOS using brew - perfringo - May-27-2021

Do you use zhs or bash? How you have set up your run-command/profile files (in case of bash .bashrc and .bash_profile). What paths are in these files etc.

Of course, using brew has some gotchas anyway, especially regarding upgrading. If you don't pin Python then brew upgradewill upgrade your Python version and this may or may not what you actually want (for dependency reasons for example).


RE: Installing Python3 on MacOS using brew - snippsat - May-27-2021

Look at The right and wrong way to set Python 3 as default on a Mac
pyenv Simple Python Version Management


RE: Installing Python3 on MacOS using brew - zazas321 - May-28-2021

I used bash. And I didint do any setup for that. I have simply followed the instructions from the website posted installing Python using brew. The initial problem was probably due to my old Python instllation that was causing the problems. The paths are as described:

/usr/local/bin
/usr/bin:/bin
/usr/sbin
/sbin
I have now sucesfully installed the Python as I mentioned above, I am just not certain regarding the version. It seems that brew installed version 3.9.5 but when I check with python3 --version it still returns 3.8.2. Can someone clarify to me again what could be the problem here exactly ?


RE: Installing Python3 on MacOS using brew - perfringo - May-28-2021

There are very many things what can be happening. What your .bashrc (or .bash_profile) says? Aren't there anything like:

alias python3="python3.8"
You can also display all python3 versions with which -a python3