Skip to content

Instantly share code, notes, and snippets.

@luck02
Last active December 10, 2022 19:47
Show Gist options
  • Save luck02/b2facbc7e3ca5e04427fc1a40e61d0db to your computer and use it in GitHub Desktop.
Save luck02/b2facbc7e3ca5e04427fc1a40e61d0db to your computer and use it in GitHub Desktop.
How I get a working python install on OSX from ground 0
Getting a working python install that's relatively sane on OSX:
* Install homebrew
* https://github.com/pyenv/pyenv#homebrew-in-macos / `brew update && brew install pyenv`
* Set up your shell for pyenv: https://github.com/pyenv/pyenv#homebrew-in-macos
* Install the python flavor of your choice: `pyenv install 3.9.10`
* Set python version: `pyenv global 3.9.10`
Getting poetry functional:
* Install poetry using the install script: https://python-poetry.org/docs/#installation
* This won't currently (2022-12-10) work with default osx python, but will work fine if pyenv is set up as above.
* Update Configs (Optional, this is how I like to use poetry...):
* `poetry config virtualenvs.prefer-active-python true`
* `poetry config virtualenvs.in-project true`
At this point you should be able to just use local pyenv without an issue or use poetry to manage your dependencies.
Getting vscode functional with Poetry, the easy way:
* Create project in terminal: `poetry new some-project`
* CD into project and run `poetry env info` and ensure it's configured the way you expect
* run `poetry shell`
* installs the correct python into `~/venv`
* run `code .` (assuming you have set up vscode with terminal config https://code.visualstudio.com/docs/setup/mac)
vscode will pick up your local project python, no need for additional configs.
I personally have always found that python the language is great, but the operational aspects of python (how to use it, which toolset to rely on) to be intensly confusing and ever changing. I'm settling on Poetry for the time being as it seems to wrap up most of the concerns nicely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment