Skip to content

Instantly share code, notes, and snippets.

@dehora
Last active June 28, 2022 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dehora/98a14eaee1f74223e7e86cc010e14863 to your computer and use it in GitHub Desktop.
Save dehora/98a14eaee1f74223e7e86cc010e14863 to your computer and use it in GitHub Desktop.
Setting up Python and pyenv on Monterey // 2022-06-28

Upgrade xcode cli tools to the most recent (this takes a while):

$ softwareupdate --list
$ softwareupdate --install "Command Line Tools for Xcode-13.4"

Watch pyenv not be able to install anything (pyenv/issues/2143), because of what seems to be a mismatch across Python, Clang and Monterey (issue45405).

Update pyenv to pick up patched versions that work (3.10.3+, 3.9.13, 3.9.9, 3.8.13, 3.7.13).

$ brew upgrade pyenv

Go ahead and install a working patched Python for Monterey (this also takes a while):

$ pyenv install 3.10.3

Create an env (in this example for a directory called py-sandbox):

$ pyenv virtualenv 3.10.3 py-sandbox
$ mkdir py-sandbox
$ cd py-sandbox
$ pyenv local py-sandbox

Check it's the right Python version:

$ python --version
Python 3.10.3

Install some basics:

$ pip install --upgrade pip
$ pip install jupyter
$ pip install pipenv
$ pip install poetry
$ pip install ipython

Make IPython pick up the env:

$ hash -r

Open IPython:

$ ipython
Python 3.10.3 (main, Jun 28 2022, 21:54:28) [Clang 13.1.6 (clang-1316.0.21.2.5)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment