turbulent / substance

Local Docker-powered development environments
Apache License 2.0
18 stars 8 forks source link

Installation on MacOS Catalina (10.15) #56

Open orditeck opened 4 years ago

orditeck commented 4 years ago

Following the current installation guide on MacOS, I noted some adjustments that should be included.

Why

When installing Python 3 with brew install python or brew install python3, it get installed as /usr/local/bin/python3. Consequently, pip for Python 3 get installed as /usr/local/bin/pip3. At the step 6 of the current installation guide on MacOS, we can read the following:

Ensure pip is up to date: sudo pip install -U pip

However, pip cannot be found. We would have to use pip3. Or link to unversioned symlinks, which is what I'm going to suggest here.

But maybe the best way would be to simply edit the guide to link to python3 and pip3. I'll leave that decision to maintainers as you are certainly more aware than me of the consequences of doing so. Initially I thought maybe substance needs python and not python3 as a binary but then I saw python3 on WSL so 🤷‍♂️

Running brew info python gives us:

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/python/libexec/bin

Use unversioned symlinks

At

  1. Make sure that running the command python executes the one under /usr/local/bin:

I suggest the following:


5. Change your path to make sure that running the command python executes the one under /usr/local/opt/python/libexec/bin:

As brew installs python3 in /usr/local/bin/, executing which python should return /usr/bin/python while which python3 should return /usr/local/bin/python3:

$ which python
/usr/bin/python
$ which pip
pip not found

$ which python3
/usr/local/bin/python3
$ which pip3
/usr/local/bin/pip3

If the command outputs /usr/local/opt/python/libexec/bin/python for which python, your installation has already been configured. As it's more likely to return the expected result we saw above, you'll have to do tell your computer to look for python somewhere else.

To do so, edit your ~/.zshrc or ~/.profile or ~/.bash_profile and add those two lines:

export PATH=/usr/local/opt/python/libexec/bin:${PATH}
export PATH=${HOME}/Library/Python/3.7/bin:${PATH}

Start a new terminal, and that should fix the issue (test it with the which commands above). The command brew doctor can also help with PATH-related problems.


About sudo

I didn't need any sudo. Is it really needed? pip install -U pip was fine pip install substance needed the --user(--user?)

So probably that step 7 should be replaced by this: pip install substance --user

To verify before updating the guide

Is it just under MacOS Catalina (10.15) or previous versions too?

Side note

From what I've read, MacOS Catalina (10.15) should be the last version to include Python 2.7. Starting from MacOS 10.16, the default will be Python 3.7.

Resources

https://github.com/Homebrew/homebrew-core/issues/15746 https://medium.com/faun/the-right-way-to-set-up-python-on-your-mac-e923ffe8cf8e