2

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 ✔, [email protected] ✔, 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.

10
  • For conda, could you please run 'conda env list'? Commented May 23, 2020 at 16:11
  • 1
    "conda search python" just shows all the versions of python they (conda) have in their repo. It means nothing to your mac, as far as I understand. You can drop that from your question. (I think) Commented May 23, 2020 at 16:13
  • 1
    and one more thing - it seems that you ran which python (in the terminal) from within a conda environment. Could you please run conda deactivate, and then run 'which python' and 'which python3' again? Commented May 23, 2020 at 16:17
  • 1
    To prevent automatically activating conda env when you open a new terminal, see this question: stackoverflow.com/questions/54429210/… Commented May 23, 2020 at 16:24
  • 1
    I have answered this in stackoverflow.com/questions/61811366/… and stackoverflow.com/questions/61823218/… in details. Commented Jun 4, 2020 at 1:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.