Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bootstrapping your Local Python Environment

Bootstrapping your Local Python Environment

You cracked open your brand new Mac or Linux dream machine and low and behold, it has Python out-of-the-box and ready to roll… Or so you think? Maybe you want to get started doing Python development on Windows and see that you can grab Python easily from the Microsoft Store. Should you? Let’s talk about getting started with the end in mind and making sure your development computer doesn’t become the next superfund site https://xkcd.com/1987/. We’ll quickly go through a tour of the various options such as pyenv, venv, virtualenv, conda and Docker as great ways to make sure you can develop in a sane environment.

4d1fa184d439599ed301821daec94063?s=128

Calvin Hendryx-Parker

July 08, 2021
Tweet

Transcript

  1. BOOTSTRAPPING YOUR LOCAL PYTHON ENVIRONMENT CALVIN HENDRYX-PARKER, CTO SIX FEET

    UP Photo by on David Clode Unsplash
  2. LET’S SET OUR INTENTION Photo by on $ python -m

    this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain it may be a good idea Sean Stratton Unsplash
  3. https://xkcd.com/1987/

  4. PYTHON LIVES IN MANY PLACES » Python provided by OS

    (macOS, RedHat, Ubuntu) » Python installed from an App Store (Microsoft Store) » Python installed from installer » Python installed from a Package Manager (apt, , ) » Python installed by a Python Distribution ( , ) python.org brew chocolatey ActiveState Anaconda
  5. SO WHY SHOULD YOU CARE ABOUT ALL OF THIS? Photo

    by on Fermin Rodriguez Penelas Unsplash
  6. STAY ZEN Beautiful is better than ugly. Explicit is better

    than implicit. Simple is better than complex.
  7. SOME RULES

  8. 🚯 NO sudo

  9. 🚯 NO sudo I DON’T CARE, NO WHINING

  10. 📵 DO NOT USE THE SYSTEM PYTHON

  11. 📵 DO NOT USE THE SYSTEM PYTHON FOR ANYTHING

  12. 🤔 OK SMART GUY

  13. PYENV » Change the global Python version on a per-user

    basis » Per-project Python versions » Override the Python version with an environment variable » Search commands from multiple versions of Python at a time https://github.com/pyenv/pyenv#installation https://pyenv-win.github.io/pyenv-win/
  14. LET’S SEE pyenv IN ACTION 🚀 Explicit is better than

    implicit.
  15. pyenv PLUGINS » virtualenv » virtualenvwrapper $ brew search pyenv

  16. virtualenv & virtualenvwrapper

  17. VIRTUAL ENVIRONMENTS ARE INCLUDED 🔋 IF YOU HAVE SIMPLE NEEDS,

    THIS IS FOR YOU! $ python -m venv venv
  18. PIPX pipx is ready to go! ✨ 🌟 ✨ https://pypa.github.io/pipx/

    $ brew install pipx $ pipx ensurepath
  19. PIPX pipx is ready to go! ✨ 🌟 ✨ https://pypa.github.io/pipx/

    $ brew install pipx $ pipx ensurepath LET’S DO SOME DAMAGE
  20. PIPX pipx is ready to go! ✨ 🌟 ✨ https://pypa.github.io/pipx/

    $ brew install pipx $ pipx ensurepath LET’S DO SOME DAMAGE $ pipx install httpie installed package httpie 2.4.0, Python 3.9.6 These apps are now globally available - http - https done! ✨ 🌟 ✨
  21. WHAT ABOUT THE “USER SCHEME”? $ python -m pip install

    --user SomePackage
  22. BUT WHAT ABOUT … » » » » » »

    Anaconda Python and Conda ActiveState Python pipenv poetry PDM pyproject.toml
  23. BUT I WANT REPEATABILITY AND SIMPLICITY… » Simple is better

    than complex. piptools
  24. I MEAN REALLY REPEATABLE… ENTER DOCKER + pip-tools

  25. QUESTIONS? CALVIN@SIXFEETUP.COM @calvinhp