MacOS Python (version) chaos. shipped, MacPorts, official installer, anaconda

Soon after diving into python, I found out there were many versions of python co-existing in my MacOS, and I don't know how to manage them. It is a disaster for me.



After spending some time, here is what I found.

OS: macOS Catalina 10.15.3
  • python installed by Apple:
      Don't change these files. Apple and other apps assumes their existences.
  1. /usr/bin/python -> /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
    may deprecate soon.
  2. /usr/bin/python3
    it is a stub if it is a fresh install,  after full installation, it is v3.7.3.
  • python installed by MacPorts:
  1. /opt/local/bin/python   -> /opt/local/bin/python3.8
  2. /opt/local/bin/python3 -> /opt/local/bin/python3.8 =>
        /opt/local/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
  3. /opt/local/bin/python2 -> /opt/local/bin/python2.7 =>
        /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
  4. I upgraded 3.7 to 3.8, and set the path accordingly.
    sudo port install python38
    sudo port select --set python   python38
    sudo port select --set python3 python38
    export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/libexec/gnubin:$PATH
    I found out that anaconda is easier to manage and use, or virtualenv if you prefer.
  • python installed by python.org installer
  1. /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
    Uninstalled. https://docs.python.org/3/using/mac.html?highlight=uninstall
    I use Anaconda now.
  • python installed by Anaconda  
    Anaconda is recommended for data science related development. Use virtualenv if you just need to manage python versions and library dependencies.
  1. /Users/xxx/anaconda3/bin/python   (v3.7.x)
  2. conda cheat sheet:
    activate default profile: conda activate
    activate a custom profile : conda activate XXX
    deactivate: conda deactivate
    create a custom profile: conda create -n XXX python
    create a custom profile with a specific python version: conda create -n XXX python=3.8.2
    install libs for a profile: conda activate XXX;  conda install pandas numpy jupyter
    search available pkgs/version: conda search python; conda search 'python>3.8'

    I treat every profile as a fresh installed python and use it both in VSCode and command line

Reference

Comments

Popular posts from this blog

DELL U4320Q ddccontrol in Linux switch input

UEFI boot.