I have installed a lot of Python versions and tools without really knowing how they work, and I've dug myself into version hell, and I could use some help digging my way out. The aim of this post is to gain control of my Python versions either by coming to understand how to navigate what I already have, or, probably better, to eliminate unnecessary paths and installations and have one place from which to manage Python use on my machine. If I have to wipe all but the default OS version of Python to set everything up right from the ground up, so be it.
I have the default OSX Python2 installation, an Anaconda installation, which I don't really know how to use, and a Homebrew installation which I don't know how to access.
From the terminal:
brew info python
shows:
python: stable 3.7.7 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.7.7 (4,006 files, 61.0MB)
Poured from bottle on 2020-05-23 at 09:31:39
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
==> Dependencies
Build: pkg-config ✘
Required: gdbm ✔, openssl@1.1 ✔, readline ✔, sqlite ✔, xz ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
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
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
==> Analytics
install: 229,317 (30 days), 1,113,249 (90 days), 5,317,787 (365 days)
install-on-request: 176,164 (30 days), 662,134 (90 days), 2,762,762 (365 days)
build-error: 0 (30 days)
which python
and python --version
show /opt/anaconda3/bin/python
and Python 3.7.4
respectively in terminal and PyCharm terminal.
From VS Code terminal, which python
shows /usr/bin/python
and python --version
shows Python 2.7.16
, while which python3
shows /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
and python3 --version
shows Python 3.7.4
.
Using pipenv to create a virtual environment in VS Code uses /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 (3.7.4)
.
My main coding platform is VS Code. I just downloaded Anaconda because it comes pre-bundled with a lot of tools I thought I might want later as I learn more.
Any advice on how to gain consistency and control in this mess would be very much appreciated.
edit: After exiting the conda environment I didn't realize I was in, using pipenv to create a virtual environment in VS Code sometimes uses /usr/local/Cellar/pipenv/2018.11.26_3/libexec/bin/python3.8 (3.8.1)
and sometimes uses /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
. I can't see why it will sometimes be one vs the other.