1

I am having trouble with my current python, so I wanted to uninstall my python and install the latest version. I installed with homebrew, so I uninstalled it with homebrew and reinstalled python 3.8.1 with the installer from the official site. Python3.8 was installed, but my python3 was not upgraded.

 ~ which python3                                      
/usr/bin/python3
 ~ python3 --version                                  
Python 3.7.3

I know I'm not supposed to(and I can't) manually delete things inside /usr/bin. What am I supposed to do?

ddoGas
  • 861
  • 7
  • 17
  • What does your `PATH` look like? `echo $PATH`. Likely `/usr/local/bin` simply isn't in it and/or `/usr/bin` has higher priority. – deceze Jan 15 '20 at 09:17
  • 1
    `~ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/usr/local/opt/fzf/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin` Sry I don’t understand. Can you explain it again? – ddoGas Jan 15 '20 at 09:21
  • That looks okay… what does `which -a python3` give you? Does it find `/usr/local/bin/python3`? – deceze Jan 15 '20 at 09:23
  • it gives me ```/usr/bin/python3``` – ddoGas Jan 15 '20 at 09:25
  • Does `/usr/local/bin/python3` actually exist? Can you execute `/usr/local/bin/python3 -V`? – deceze Jan 15 '20 at 09:25
  • ```/usr/local/bin/python3.8``` exists no `/usr/local/bin/python3`? – ddoGas Jan 15 '20 at 09:28
  • Well, there's your problem…!? – deceze Jan 15 '20 at 09:28
  • Yes. I'm not sure if there's a reason for brew not to create a `python3` symlink as well and whether that's worth fixing. Using `python3.8` instead of `python3` should at least work. If you want to dig into why `/usr/local/bin/python3` wasn't created by brew, you should post a more detailed and specific question about that. In practice you should be using virtualenvs a lot, so the entire issue largely becomes moot once you've created a virtualenv for your project and just use `python` within it. – deceze Jan 15 '20 at 09:32
  • Got it. Thx a bunch. – ddoGas Jan 15 '20 at 09:37

2 Answers2

4

When you installed Python with homebrew it told you this:

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

If you need a reminder, post install, you will get the same message if you run:

brew info python

It says "unversioned links are in /usr/local/opt/python/libexec/bin". That means, if you want to run Python without specifying the version, i.e. if you want to type this:

python

and this:

pip

to start Python 3 and its corresponding pip, you need to make sure your PATH has /usr/local/opt/python/libexec/bin at the start, i.e.

export PATH=/usr/local/opt/python/libexec/bin:$PATH
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Any reasons behind it? Why can /usr/local/bin has all the unversioned links? Potentially, conflicts with other system components? – jiggysoo Aug 10 '20 at 14:57
1

I could not uninstall the python3 in /usr/bin but found a workaround to give the python3 in /usr/loca/bin precedence by setting the PATH env variable as PATH=/usr/local/bin:$PATH. This gives binaries in /usr/local/bin precedence. Not a full fledged solution, but got me moving.