SlideShare a Scribd company logo
Sebastian Witowski
Python Versions and
Dependencies Made Easy
Sebastian Witowski
Python consultant, freelancer, and trainer
@SebaWitowski switowski.com
Problem with (Python) projects
@SebaWitowski switowski.com
Problem with (Python) projects
Stuck in the 90s
Over-engineered
@SebaWitowski switowski.com
Problem with (Python) projects
Over-engineered
• Too many shiny new tools from
HackerNews

• Those tools gets abandoned

• You spend too much time
replacing old tools with new ones
Stuck in the 90s
@SebaWitowski switowski.com
Problem with (Python) projects
Over-engineered
• Too many shiny new tools from
HackerNews

• Those tools gets abandoned

• You spend too much time
replacing old tools with new ones
Stuck in the 90s
• Everything managed with Bash
scripts

• You have to maintain Bash
scripts or some other scripts
(as a Python developer)
@SebaWitowski switowski.com
How about a middle ground?
@SebaWitowski switowski.com
What will we talk about?
• pyenv - installing different Python versions on your computer
@SebaWitowski switowski.com
What will we talk about?
• pyenv - installing different Python versions on your computer

• venv - isolating dependencies of your projects
@SebaWitowski switowski.com
What will we talk about?
• pyenv - installing different Python versions on your computer

• venv - isolating dependencies of your projects 

• pipx - installing global packages
@SebaWitowski switowski.com
What will we talk about?
• pyenv - installing different Python versions on your computer

• venv - isolating dependencies of your projects 

• pipx - installing global packages

• pip-tools - dependency pinning
@SebaWitowski switowski.com
Installing Python
System Python
macOS
Ubuntu 20.04
Debian 10
@SebaWitowski
• Python version preinstalled on your OS is called “system Python”
System Python
@SebaWitowski switowski.com
• Python version preinstalled on your OS is called “system Python”

• Please, don’t use it
System Python
@SebaWitowski switowski.com
• Python version preinstalled on your OS is called “system Python”

• Please, don’t use it

• And don’t update it (you might break your OS)!
System Python
@SebaWitowski switowski.com
How to install a new Python version?
@SebaWitowski switowski.com
• Use an installer from python.org
How to install a new Python version?
@SebaWitowski switowski.com
• Use an installer from python.org

• Use your package manager
How to install a new Python version?
@SebaWitowski switowski.com
• Use an installer from python.org

• Use your package manager

• Compile it from the source files
How to install a new Python version?
@SebaWitowski switowski.com
Or you can use pyenv!
https://github.com/pyenv/pyenv
@SebaWitowski switowski.com
Or pyenv-win for Windows
https://github.com/pyenv-win/pyenv-win
@SebaWitowski switowski.com
Installing pyenv
@SebaWitowski switowski.com
Installing pyenv
@SebaWitowski switowski.com
Using pyenv
1. Find Python version to install
$ pyenv install --list
Available versions:
2.1.3
2.2.3
2.3.7
2.4.0
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
2.4.6
2.5.0
2.5.1
2.5.2
2.5.3
2.5.4
...
...
3.9.0
3.9-dev
3.10-dev
activepython-2.7.14
activepython-3.5.4
activepython-3.6.0
anaconda-1.4.0
anaconda-1.5.0
anaconda-1.5.1
anaconda-1.6.0
anaconda-1.6.1
anaconda-1.7.0
anaconda-1.8.0
anaconda-1.9.0
...
...
miniconda3-4.7.12
pypy-c-jit-latest
pypy-c-nojit-latest
pypy-dev
pypy-stm-2.3
pypy-stm-2.5.1
pypy-1.5-src
pypy-1.5
pypy-1.6
pypy-1.7
pypy-1.8
pypy-1.9
pypy-2.0-src
pypy-2.0
...
...
pypy3.6-7.3.0
pypy3.6-7.3.1-src
pypy3.6-7.3.1
pyston-0.5.1
pyston-0.6.0
pyston-0.6.1
stackless-dev
stackless-2.7-dev
stackless-2.7.2
stackless-2.7.3
stackless-2.7.4
stackless-2.7.5
stackless-2.7.6
...
@SebaWitowski switowski.com
Using pyenv
1. Find Python version to install
2. Install it
$ pyenv install 3.9.0
...
# Wait for a few minutes
...
# Done!
@SebaWitowski switowski.com
Using pyenv
1. Find Python version to install
2. Install it
3. Check if it’s installed correctly
$ pyenv versions
* system
3.9.0
@SebaWitowski switowski.com
Using pyenv
1. Find Python version to install
2. Install it
3. Check if it’s installed correctly
4. Start using this version
$ pyenv global 3.9.0
# or
$ pyenv local 3.9.0
# or
$ pyenv shell 3.9.0
@SebaWitowski switowski.com
3 levels of pyenv
• pyenv global 3.9.0 - changes the global Python version on your computer
@SebaWitowski switowski.com
3 levels of pyenv
• pyenv global 3.9.0 - changes the global Python version on your computer

• pyenv local 3.9.0 - changes Python version for the current folder and all the
sub-folders
@SebaWitowski switowski.com
3 levels of pyenv
• pyenv global 3.9.0 - changes the global Python version on your computer

• pyenv local 3.9.0 - changes Python version for the current folder and all the
sub-folders
# projectA
$ pyenv local 3.9.0
# projectB
$ pyenv local 3.6.0
@SebaWitowski switowski.com
3 levels of pyenv
• pyenv global 3.9.0 - changes the global Python version on your computer

• pyenv local 3.9.0 - changes Python version for the current folder and all the
sub-folders

• pyenv shell 2.7.18 - changes Python version for the current shell session
@SebaWitowski switowski.com
Problem with pip
You can only have one version of a given package installed!
@SebaWitowski switowski.com
$ pip install Django
...
Django 3.0 installed!
Problem with pip
@SebaWitowski switowski.com
Problem with pip
$ pip install Django==2.2
...
...
...
Django 2.2 installed!
@SebaWitowski switowski.com
$ pip install Django==2.2
...
Django==3.0 uninstalled!
...
Django 2.2 installed!
Problem with pip
@SebaWitowski switowski.com
# .../lib/python3.9/site-packages
$ ls -al
...
drwxr-xr-x 22 switowski 704 Oct 30 12:41 django/
drwxr-xr-x 12 switowski 384 Oct 30 12:41 django_redis/
drwxr-xr-x 16 switowski 512 Sep 28 17:58 docutils/
...
Problem with pip
@SebaWitowski switowski.com
# .../lib/python3.9/site-packages
$ ls -al
...
drwxr-xr-x 22 switowski 704 Oct 30 12:41 django/
drwxr-xr-x 12 switowski 384 Oct 30 12:41 django_redis/
drwxr-xr-x 16 switowski 512 Sep 28 17:58 docutils/
...
Problem with pip
@SebaWitowski switowski.com
Virtual environment
If pip installs every package in the same folder, why can’t we tell
it to temporarily install them in a different folder?
@SebaWitowski switowski.com
Virtual environment
If pip installs every package in the same folder, why can’t we tell
it to temporarily install them in a different folder?
Virtual environment:

• Creates a special folder with Python binaries

• Tells pip to install new packages to that folder

• Tells Python to use packages from that folder
@SebaWitowski switowski.com
Using virtual environments
1. Create new virtual environment
$ python -m venv .venv
@SebaWitowski switowski.com
Using virtual environments
1. Create new virtual environment
2. Activate it
$ source .venv/bin/activate
@SebaWitowski switowski.com
Using virtual environments
1. Create new virtual environment
2. Activate it
$ source .venv/bin/activate
# Your prompt should change:
(venv) $
@SebaWitowski switowski.com
Using virtual environments
1. Create new virtual environment
2. Activate it
3. Work on your Python project (install packages, run Python)
(venv) $ pip install Django==2.2
...
(venv) $ python manage.py runserver
@SebaWitowski switowski.com
Using virtual environments
1. Create new virtual environment
2. Activate it
3. Work on your Python project (install packages, run Python)
4. Deactivate virtual environment to stop using it
(venv) $ deactivate
$
@SebaWitowski switowski.com
Typical workflow
# Inside Django 3 project folder
$ python -m venv django3-app
$ source django3-app/bin/activate
$ pip install django==3.0
# Inside Django 2 project folder
$ python -m venv django2-app
$ source django2-app/bin/activate
$ pip install django==2.2
@SebaWitowski switowski.com
virtualenvwrapper
Windows users: https://pypi.org/project/virtualenvwrapper-win/
Linux and macOS:
@SebaWitowski switowski.com
virtualenvwrapper
virtualenvwrapper stores all virtual environments in:
~/.virtualenvs/
@SebaWitowski switowski.com
virtualenvwrapper
virtualenvwrapper stores all virtual environments in:
~/.virtualenvs/
$ mkvirtualenv django2-app - create a virtual environment
$ workon django2-app - activate it
$ lsvirtualenv - list all virtual environments
$ rmvirtualenv django2-app - delete a virtual environment
@SebaWitowski switowski.com
venv or virtualenvwrapper?
@SebaWitowski switowski.com
Global Python packages
• Some tools should be installed globally (black, flake8, virtualenvwrapper)
@SebaWitowski switowski.com
Global Python packages
• Some tools should be installed globally (black, flake8, virtualenvwrapper)

• But if they require different versions of the same dependency, one of them
will break
@SebaWitowski switowski.com
Global Python packages
• Some tools should be installed globally (black, flake8, virtualenvwrapper)

• But if they require different versions of the same dependency, one of them
will break

• Installing global tools into separate virtual environments is a hassle (you
have to activate each virtual environment to use that tool)
@SebaWitowski switowski.com
pipx - global packages in separate environments
https://github.com/pipxproject/pipx
@SebaWitowski switowski.com
pipx in action
1. Install “black” package
$ pipx install black
installed package black 20.8b1, Python 3.8.5
These apps are now globally available
- black
- black-primer
- blackd
done! ✨ 🌟 ✨
@SebaWitowski switowski.com
pipx in action
1. Install “black” package
2. Use black
$ black hello_world.py
reformatted hello_world.py
All done! ✨ 🍰 ✨
1 file reformatted.
@SebaWitowski switowski.com
pipx in action
1. Install “black” package
2. Use black
3. “black” installed in a virtual env will shadow the global one
# Inside a virtual environment
(venv) $ black --version
black, version 19.3b0
# Outside of a virtual environment
$ black --version
black, version 20.8b1
@SebaWitowski switowski.com
pipx commands
$ pipx list - list all installed packages
$ pipx uninstall <package> - uninstall package
$ pipx upgrade-all - upgrade all packages
$ pipx inject pytest pytest-cov - install pytest-cov inside
pytest virtual env
@SebaWitowski switowski.com
Dependencies in your project
@SebaWitowski switowski.com
Dependencies in your project
# requirements.txt
Django
django-redis
pytest
@SebaWitowski switowski.com
Dependencies in your project
# requirements.txt
Django
django-redis
pytest
$ pip install -r requirements.txt
...
Successfully installed Django-2.2, ...
@SebaWitowski switowski.com
Dependencies in your project
# requirements.txt
Django
django-redis
pytest
$ pip install -r requirements.txt
...
Successfully installed Django-2.2, ...
$ pip install -r requirements.txt
...
Successfully installed Django-3.0, ...
One month later…
Dependencies in your project
# requirements.txt
Django
django-redis
pytest
$ pip install -r requirements.txt
...
Successfully installed Django-2.2, ...
$ pip install -r requirements.txt
...
Successfully installed Django-3.0, ...
One month later…
Dependencies in your project
# requirements.txt
Django>=2.2,<3.0
django-redis==4.12.0
pytest==5.*
Dependency pinning:
@SebaWitowski switowski.com
Dependencies in your project
Always pin dependencies on production servers!
@SebaWitowski switowski.com
Dependencies in your project
Always pin dependencies on production servers!
And their sub-dependencies (3rd party packages)!
@SebaWitowski switowski.com
Dependencies in your project
Always pin dependencies on production servers!
And their sub-dependencies (3rd party packages)!
And don’t forget to update packages regularly!
@SebaWitowski switowski.com
Dependencies in your project
Always pin dependencies on production servers!
And their sub-dependencies (3rd party packages)!
And don’t forget to update packages regularly!
That’s a lot of work!
@SebaWitowski switowski.com
Pipenv and Poetry to the rescue!
But do you really need them?
@SebaWitowski switowski.com
But do you really need them?
• What if they stop working?
@SebaWitowski switowski.com
But do you really need them?
• What if they stop working?

• What if they get discontinued?
@SebaWitowski switowski.com
But do you really need them?
• What if they stop working?

• What if they get discontinued?

• Do you really use ALL their features?
@SebaWitowski switowski.com
Pipenv and Poetry are great
@SebaWitowski switowski.com
But sometimes a simpler tool is enough
Pipenv and Poetry are great
@SebaWitowski switowski.com
But sometimes a simpler tool is enough
Pipenv and Poetry are great
https://github.com/jazzband/pip-tools
@SebaWitowski switowski.com
pip-compile
@SebaWitowski switowski.com
pip-compile
# requirements.in
Django>=2.2>,<3.0
pytest
# requirements.txt
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
attrs==20.2.0 # via pytest
django==2.2.17 # via -r requirements.in
importlib-metadata==2.0.0 # via pluggy, pytest
iniconfig==1.1.1 # via pytest
packaging==20.4 # via pytest
pluggy==0.13.1 # via pytest
py==1.9.0 # via pytest
pyparsing==2.4.7 # via packaging
pytest==6.1.2 # via -r requirements.in
pytz==2020.4 # via django
six==1.15.0 # via packaging
sqlparse==0.4.1 # via django
toml==0.10.2 # via pytest
zipp==3.4.0 # via importlib-metadata
$ pip-compile requirements.in
pip-compile
# requirements.txt
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
attrs==20.2.0 # via pytest
django==2.2.17 # via -r requirements.in
importlib-metadata==2.0.0 # via pluggy, pytest
iniconfig==1.1.1 # via pytest
packaging==20.4 # via pytest
pluggy==0.13.1 # via pytest
py==1.9.0 # via pytest
pyparsing==2.4.7 # via packaging
pytest==6.1.2 # via -r requirements.in
pytz==2020.4 # via django
six==1.15.0 # via packaging
sqlparse==0.4.1 # via django
toml==0.10.2 # via pytest
zipp==3.4.0 # via importlib-metadata
@SebaWitowski switowski.com
pip-compile
# requirements.txt
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
attrs==20.2.0 # via pytest
django==2.2.17 # via -r requirements.in
importlib-metadata==2.0.0 # via pluggy, pytest
iniconfig==1.1.1 # via pytest
packaging==20.4 # via pytest
pluggy==0.13.1 # via pytest
py==1.9.0 # via pytest
pyparsing==2.4.7 # via packaging
pytest==6.1.2 # via -r requirements.in
pytz==2020.4 # via django
six==1.15.0 # via packaging
sqlparse==0.4.1 # via django
toml==0.10.2 # via pytest
zipp==3.4.0 # via importlib-metadata
@SebaWitowski switowski.com
pip-compile
# requirements.txt
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
attrs==20.2.0 # via pytest
django==2.2.17 # via -r requirements.in
importlib-metadata==2.0.0 # via pluggy, pytest
iniconfig==1.1.1 # via pytest
packaging==20.4 # via pytest
pluggy==0.13.1 # via pytest
py==1.9.0 # via pytest
pyparsing==2.4.7 # via packaging
pytest==6.1.2 # via -r requirements.in
pytz==2020.4 # via django
six==1.15.0 # via packaging
sqlparse==0.4.1 # via django
toml==0.10.2 # via pytest
zipp==3.4.0 # via importlib-metadata
@SebaWitowski switowski.com
pip-compile
# requirements.txt
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
attrs==20.2.0 # via pytest
django==2.2.17 # via -r requirements.in
importlib-metadata==2.0.0 # via pluggy, pytest
iniconfig==1.1.1 # via pytest
packaging==20.4 # via pytest
pluggy==0.13.1 # via pytest
py==1.9.0 # via pytest
pyparsing==2.4.7 # via packaging
pytest==6.1.2 # via -r requirements.in
pytz==2020.4 # via django
six==1.15.0 # via packaging
sqlparse==0.4.1 # via django
toml==0.10.2 # via pytest
zipp==3.4.0 # via importlib-metadata
@SebaWitowski switowski.com
pip-compile
# requirements.txt
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
attrs==20.2.0 # via pytest
django==2.2.17 # via -r requirements.in
importlib-metadata==2.0.0 # via pluggy, pytest
iniconfig==1.1.1 # via pytest
packaging==20.4 # via pytest
pluggy==0.13.1 # via pytest
py==1.9.0 # via pytest
pyparsing==2.4.7 # via packaging
pytest==6.1.2 # via -r requirements.in
pytz==2020.4 # via django
six==1.15.0 # via packaging
sqlparse==0.4.1 # via django
toml==0.10.2 # via pytest
zipp==3.4.0 # via importlib-metadata
@SebaWitowski switowski.com
pip-compile
Now, run:
$ pip install -r requirements.txt
@SebaWitowski switowski.com
pip-compile
Now, run:
$ pip install -r requirements.txt
Need to update dependencies?
$ pip-compile requirements.in
@SebaWitowski switowski.com
pip-compile
Make pip-compile part of your CI
@SebaWitowski switowski.com
pip-compile
Make pip-compile part of your CI
If something breaks, pin that package in requirements.in
@SebaWitowski switowski.com
pip-sync
@SebaWitowski switowski.com
pip-tools
vs.
Pipenv and Poetry
@SebaWitowski switowski.com
Summary
@SebaWitowski switowski.com
Summary
• Use pyenv to install/update Python versions
@SebaWitowski switowski.com
Summary
• Use pyenv to install/update Python versions
• Use venv/virtualenvwrapper to isolate dependencies of your projects
@SebaWitowski switowski.com
Summary
• Use pyenv to install/update Python versions
• Use venv/virtualenvwrapper to isolate dependencies of your projects
• Use pipx to install global tools
@SebaWitowski switowski.com
Summary
• Use pyenv to install/update Python versions
• Use venv/virtualenvwrapper to isolate dependencies of your projects
• Use pipx to install global tools
• Consider pip-tools when you just need to pin dependencies
@SebaWitowski switowski.com
Where to go next?
@SebaWitowski switowski.com
Where to go next?
“Modern Python Projects” workshop (part of this conference)
@SebaWitowski switowski.com
Where to go next?
“Modern Python Projects” online course
https://modernpythonprojects.com/
@SebaWitowski switowski.com

More Related Content

What's hot (20)

Bootstrap
BootstrapBootstrap
Bootstrap
Jadson Santos
 
Curso HTML y CSS, parte 1
Curso HTML y CSS, parte 1Curso HTML y CSS, parte 1
Curso HTML y CSS, parte 1
Sergio Nouvel Castro
 
Taller Historias de usuario 20130117
Taller Historias de usuario 20130117Taller Historias de usuario 20130117
Taller Historias de usuario 20130117
Jose Manuel Beas
 
Diagrama de despliegue
Diagrama de despliegueDiagrama de despliegue
Diagrama de despliegue
ElvisAR
 
Historias de usuario
Historias de usuarioHistorias de usuario
Historias de usuario
Joan SebastiĂĄn RamĂ­rez PĂŠrez
 
Slicing and testing
Slicing and testingSlicing and testing
Slicing and testing
TaegeonLee1
 
Marcos de gobierno de ti
Marcos de gobierno de tiMarcos de gobierno de ti
Marcos de gobierno de ti
Rosmery Banr
 
Evolutionary Software Process Module in Easy Terminology by Taha Shahid
Evolutionary Software Process Module in Easy Terminology by Taha ShahidEvolutionary Software Process Module in Easy Terminology by Taha Shahid
Evolutionary Software Process Module in Easy Terminology by Taha Shahid
Tahaa Shahid
 
Tecnicas de estimacion de software
Tecnicas de estimacion de softwareTecnicas de estimacion de software
Tecnicas de estimacion de software
Ades27
 
Tolerencia de fallas
Tolerencia de fallasTolerencia de fallas
Tolerencia de fallas
IvĂĄn Sanchez Vera
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagram
Baskarkncet
 
Tema2: TecnologĂ­as de desarrollo web (Desarrollo Aplicaciones Web)
Tema2: TecnologĂ­as de desarrollo web (Desarrollo Aplicaciones Web)Tema2: TecnologĂ­as de desarrollo web (Desarrollo Aplicaciones Web)
Tema2: TecnologĂ­as de desarrollo web (Desarrollo Aplicaciones Web)
Micael Gallego
 
Artefactos Arquitectura Empresarial Biblioteca Digital
Artefactos Arquitectura Empresarial Biblioteca DigitalArtefactos Arquitectura Empresarial Biblioteca Digital
Artefactos Arquitectura Empresarial Biblioteca Digital
Diego Fernando GonzĂĄlez Cabezas
 
Diagrama de actividades uml
Diagrama de actividades umlDiagrama de actividades uml
Diagrama de actividades uml
camiloan40
 
Sqa ejemplo
Sqa ejemploSqa ejemplo
Sqa ejemplo
Jose Limon
 
Arquitecturas de pizarra o repositĂłrio
Arquitecturas de pizarra o repositĂłrioArquitecturas de pizarra o repositĂłrio
Arquitecturas de pizarra o repositĂłrio
rehoscript
 
Rentabilidad de los proyectos software
Rentabilidad de los proyectos softwareRentabilidad de los proyectos software
Rentabilidad de los proyectos software
EOI Escuela de OrganizaciĂłn Industrial
 
BLACK BOX & WHITE BOX TESTING.pptx
BLACK BOX & WHITE BOX TESTING.pptxBLACK BOX & WHITE BOX TESTING.pptx
BLACK BOX & WHITE BOX TESTING.pptx
MohammadShahjalalKha
 
Buenas PrĂĄcticas en GestiĂłn de Servicios de TI
Buenas PrĂĄcticas en GestiĂłn de Servicios de TIBuenas PrĂĄcticas en GestiĂłn de Servicios de TI
Buenas PrĂĄcticas en GestiĂłn de Servicios de TI
Software Guru
 
Los controles de aplicacion
Los controles de aplicacionLos controles de aplicacion
Los controles de aplicacion
Maria de Lourdes Castillero
 
Taller Historias de usuario 20130117
Taller Historias de usuario 20130117Taller Historias de usuario 20130117
Taller Historias de usuario 20130117
Jose Manuel Beas
 
Diagrama de despliegue
Diagrama de despliegueDiagrama de despliegue
Diagrama de despliegue
ElvisAR
 
Slicing and testing
Slicing and testingSlicing and testing
Slicing and testing
TaegeonLee1
 
Marcos de gobierno de ti
Marcos de gobierno de tiMarcos de gobierno de ti
Marcos de gobierno de ti
Rosmery Banr
 
Evolutionary Software Process Module in Easy Terminology by Taha Shahid
Evolutionary Software Process Module in Easy Terminology by Taha ShahidEvolutionary Software Process Module in Easy Terminology by Taha Shahid
Evolutionary Software Process Module in Easy Terminology by Taha Shahid
Tahaa Shahid
 
Tecnicas de estimacion de software
Tecnicas de estimacion de softwareTecnicas de estimacion de software
Tecnicas de estimacion de software
Ades27
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagram
Baskarkncet
 
Tema2: TecnologĂ­as de desarrollo web (Desarrollo Aplicaciones Web)
Tema2: TecnologĂ­as de desarrollo web (Desarrollo Aplicaciones Web)Tema2: TecnologĂ­as de desarrollo web (Desarrollo Aplicaciones Web)
Tema2: TecnologĂ­as de desarrollo web (Desarrollo Aplicaciones Web)
Micael Gallego
 
Diagrama de actividades uml
Diagrama de actividades umlDiagrama de actividades uml
Diagrama de actividades uml
camiloan40
 
Sqa ejemplo
Sqa ejemploSqa ejemplo
Sqa ejemplo
Jose Limon
 
Arquitecturas de pizarra o repositĂłrio
Arquitecturas de pizarra o repositĂłrioArquitecturas de pizarra o repositĂłrio
Arquitecturas de pizarra o repositĂłrio
rehoscript
 
BLACK BOX & WHITE BOX TESTING.pptx
BLACK BOX & WHITE BOX TESTING.pptxBLACK BOX & WHITE BOX TESTING.pptx
BLACK BOX & WHITE BOX TESTING.pptx
MohammadShahjalalKha
 
Buenas PrĂĄcticas en GestiĂłn de Servicios de TI
Buenas PrĂĄcticas en GestiĂłn de Servicios de TIBuenas PrĂĄcticas en GestiĂłn de Servicios de TI
Buenas PrĂĄcticas en GestiĂłn de Servicios de TI
Software Guru
 

Similar to Python Versions and Dependencies Made Easy (20)

Python Programming-Lesson 1- Installation and Environmental Set-up.pptx
Python Programming-Lesson 1- Installation and Environmental Set-up.pptxPython Programming-Lesson 1- Installation and Environmental Set-up.pptx
Python Programming-Lesson 1- Installation and Environmental Set-up.pptx
BautistaAljhonG
 
Django Dev Environment Howto
Django Dev Environment HowtoDjango Dev Environment Howto
Django Dev Environment Howto
Tzu-ping Chung
 
Run Python on windows
Run Python on windowsRun Python on windows
Run Python on windows
Sitthykun LY
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
WEBdeBS
 
Python Course
Python CoursePython Course
Python Course
Sourabh Sahu
 
Effectively using Open Source with conda
Effectively using Open Source with condaEffectively using Open Source with conda
Effectively using Open Source with conda
Travis Oliphant
 
Py Day Mallorca - Pipenv - Python Dev Workflow for Humans
Py Day Mallorca  - Pipenv - Python Dev Workflow for HumansPy Day Mallorca  - Pipenv - Python Dev Workflow for Humans
Py Day Mallorca - Pipenv - Python Dev Workflow for Humans
Andreu Vallbona Plazas
 
Pip + virtualenv
Pip + virtualenvPip + virtualenv
Pip + virtualenv
Daryl Yu
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of Python
Asia Smith
 
Python 1
Python 1Python 1
Python 1
Jainul Musani
 
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development EnvironmentPython Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Devloper
 
Packaging in Python? Don't Roll the Dice.
Packaging in Python? Don't Roll the Dice.Packaging in Python? Don't Roll the Dice.
Packaging in Python? Don't Roll the Dice.
ldaws
 
Pipenv - The Python Companion You Wish You Always Had
Pipenv - The Python Companion You Wish You Always HadPipenv - The Python Companion You Wish You Always Had
Pipenv - The Python Companion You Wish You Always Had
Avi Aminov
 
venv and pip.pdf
venv and pip.pdfvenv and pip.pdf
venv and pip.pdf
JonathanArp3
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Codemotion
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
Vijay Chaitanya
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
Akhil Kaushik
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
Mattupallipardhu
 
10 11-hart installing pythonsoftware
10 11-hart installing pythonsoftware10 11-hart installing pythonsoftware
10 11-hart installing pythonsoftware
William Hart
 
E D - Environmental Dependencies in Python
E D - Environmental Dependencies in PythonE D - Environmental Dependencies in Python
E D - Environmental Dependencies in Python
Adam Englander
 
Python Programming-Lesson 1- Installation and Environmental Set-up.pptx
Python Programming-Lesson 1- Installation and Environmental Set-up.pptxPython Programming-Lesson 1- Installation and Environmental Set-up.pptx
Python Programming-Lesson 1- Installation and Environmental Set-up.pptx
BautistaAljhonG
 
Django Dev Environment Howto
Django Dev Environment HowtoDjango Dev Environment Howto
Django Dev Environment Howto
Tzu-ping Chung
 
Run Python on windows
Run Python on windowsRun Python on windows
Run Python on windows
Sitthykun LY
 
Virtualenv
VirtualenvVirtualenv
Virtualenv
WEBdeBS
 
Python Course
Python CoursePython Course
Python Course
Sourabh Sahu
 
Effectively using Open Source with conda
Effectively using Open Source with condaEffectively using Open Source with conda
Effectively using Open Source with conda
Travis Oliphant
 
Py Day Mallorca - Pipenv - Python Dev Workflow for Humans
Py Day Mallorca  - Pipenv - Python Dev Workflow for HumansPy Day Mallorca  - Pipenv - Python Dev Workflow for Humans
Py Day Mallorca - Pipenv - Python Dev Workflow for Humans
Andreu Vallbona Plazas
 
Pip + virtualenv
Pip + virtualenvPip + virtualenv
Pip + virtualenv
Daryl Yu
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of Python
Asia Smith
 
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development EnvironmentPython Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Python Devloper
 
Packaging in Python? Don't Roll the Dice.
Packaging in Python? Don't Roll the Dice.Packaging in Python? Don't Roll the Dice.
Packaging in Python? Don't Roll the Dice.
ldaws
 
Pipenv - The Python Companion You Wish You Always Had
Pipenv - The Python Companion You Wish You Always HadPipenv - The Python Companion You Wish You Always Had
Pipenv - The Python Companion You Wish You Always Had
Avi Aminov
 
venv and pip.pdf
venv and pip.pdfvenv and pip.pdf
venv and pip.pdf
JonathanArp3
 
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Christian Strappazzon - Presentazione Python Milano - Codemotion Milano 2017
Codemotion
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
Akhil Kaushik
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
Mattupallipardhu
 
10 11-hart installing pythonsoftware
10 11-hart installing pythonsoftware10 11-hart installing pythonsoftware
10 11-hart installing pythonsoftware
William Hart
 
E D - Environmental Dependencies in Python
E D - Environmental Dependencies in PythonE D - Environmental Dependencies in Python
E D - Environmental Dependencies in Python
Adam Englander
 
Ad

More from Sebastian Witowski (7)

5 Things I Wish I Knew About Gitlab CI
5 Things I Wish I Knew About Gitlab CI5 Things I Wish I Knew About Gitlab CI
5 Things I Wish I Knew About Gitlab CI
Sebastian Witowski
 
Optimizing Your CI Pipelines
Optimizing Your CI PipelinesOptimizing Your CI Pipelines
Optimizing Your CI Pipelines
Sebastian Witowski
 
Writing Faster Python 3
Writing Faster Python 3Writing Faster Python 3
Writing Faster Python 3
Sebastian Witowski
 
Productivity tips for developers
Productivity tips for developersProductivity tips for developers
Productivity tips for developers
Sebastian Witowski
 
Wait, IPython can do that?! (30 minutes)
Wait, IPython can do that?! (30 minutes)Wait, IPython can do that?! (30 minutes)
Wait, IPython can do that?! (30 minutes)
Sebastian Witowski
 
It's 2019 & I'm still using Python 2! Should I be worried?
It's 2019 & I'm still using Python 2! Should I be worried?It's 2019 & I'm still using Python 2! Should I be worried?
It's 2019 & I'm still using Python 2! Should I be worried?
Sebastian Witowski
 
Wait, IPython can do that?
Wait, IPython can do that?Wait, IPython can do that?
Wait, IPython can do that?
Sebastian Witowski
 
5 Things I Wish I Knew About Gitlab CI
5 Things I Wish I Knew About Gitlab CI5 Things I Wish I Knew About Gitlab CI
5 Things I Wish I Knew About Gitlab CI
Sebastian Witowski
 
Optimizing Your CI Pipelines
Optimizing Your CI PipelinesOptimizing Your CI Pipelines
Optimizing Your CI Pipelines
Sebastian Witowski
 
Productivity tips for developers
Productivity tips for developersProductivity tips for developers
Productivity tips for developers
Sebastian Witowski
 
Wait, IPython can do that?! (30 minutes)
Wait, IPython can do that?! (30 minutes)Wait, IPython can do that?! (30 minutes)
Wait, IPython can do that?! (30 minutes)
Sebastian Witowski
 
It's 2019 & I'm still using Python 2! Should I be worried?
It's 2019 & I'm still using Python 2! Should I be worried?It's 2019 & I'm still using Python 2! Should I be worried?
It's 2019 & I'm still using Python 2! Should I be worried?
Sebastian Witowski
 
Wait, IPython can do that?
Wait, IPython can do that?Wait, IPython can do that?
Wait, IPython can do that?
Sebastian Witowski
 
Ad

Recently uploaded (20)

Issues in AI Presentation and machine learning.pptx
Issues in AI Presentation and machine learning.pptxIssues in AI Presentation and machine learning.pptx
Issues in AI Presentation and machine learning.pptx
Jalalkhan657136
 
Top 10 Mobile Banking Apps in the USA.pdf
Top 10 Mobile Banking Apps in the USA.pdfTop 10 Mobile Banking Apps in the USA.pdf
Top 10 Mobile Banking Apps in the USA.pdf
LL Technolab
 
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
gauravvmanchandaa200
 
The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...
Prachi Desai
 
Facility Management Solution - TeroTAM CMMS Software
Facility Management Solution - TeroTAM CMMS SoftwareFacility Management Solution - TeroTAM CMMS Software
Facility Management Solution - TeroTAM CMMS Software
TeroTAM
 
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire
 
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdfSecure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Northwind Technologies
 
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdfHow a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
mary rojas
 
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdfBoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
Ortus Solutions, Corp
 
AI Alternative - Discover the best AI tools and their alternatives
AI Alternative - Discover the best AI tools and their alternativesAI Alternative - Discover the best AI tools and their alternatives
AI Alternative - Discover the best AI tools and their alternatives
AI Alternative
 
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjaraswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
muhammadalikhanalikh1
 
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdfHow to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
QuickBooks Training
 
zOS CommServer support for the Network Express feature on z17
zOS CommServer support for the Network Express feature on z17zOS CommServer support for the Network Express feature on z17
zOS CommServer support for the Network Express feature on z17
zOSCommserver
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
iOS Developer Resume 2025 | Pramod Kumar
iOS Developer Resume 2025 | Pramod KumariOS Developer Resume 2025 | Pramod Kumar
iOS Developer Resume 2025 | Pramod Kumar
Pramod Kumar
 
Techdebt handling with cleancode focus and as risk taker
Techdebt handling with cleancode focus and as risk takerTechdebt handling with cleancode focus and as risk taker
Techdebt handling with cleancode focus and as risk taker
RajaNagendraKumar
 
Software Risk and Quality management.pptx
Software Risk and Quality management.pptxSoftware Risk and Quality management.pptx
Software Risk and Quality management.pptx
HassanBangash9
 
Marketing And Sales Software Services.pptx
Marketing And Sales Software Services.pptxMarketing And Sales Software Services.pptx
Marketing And Sales Software Services.pptx
julia smits
 
Boost Student Engagement with Smart Attendance Software for Schools
Boost Student Engagement with Smart Attendance Software for SchoolsBoost Student Engagement with Smart Attendance Software for Schools
Boost Student Engagement with Smart Attendance Software for Schools
Visitu
 
Agentic AI Desgin Principles in five slides.pptx
Agentic AI Desgin Principles in five slides.pptxAgentic AI Desgin Principles in five slides.pptx
Agentic AI Desgin Principles in five slides.pptx
MOSIUOA WESI
 
Issues in AI Presentation and machine learning.pptx
Issues in AI Presentation and machine learning.pptxIssues in AI Presentation and machine learning.pptx
Issues in AI Presentation and machine learning.pptx
Jalalkhan657136
 
Top 10 Mobile Banking Apps in the USA.pdf
Top 10 Mobile Banking Apps in the USA.pdfTop 10 Mobile Banking Apps in the USA.pdf
Top 10 Mobile Banking Apps in the USA.pdf
LL Technolab
 
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
Risk Management in Software Projects: Identifying, Analyzing, and Controlling...
gauravvmanchandaa200
 
The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...The rise of e-commerce has redefined how retailers operate—and reconciliation...
The rise of e-commerce has redefined how retailers operate—and reconciliation...
Prachi Desai
 
Facility Management Solution - TeroTAM CMMS Software
Facility Management Solution - TeroTAM CMMS SoftwareFacility Management Solution - TeroTAM CMMS Software
Facility Management Solution - TeroTAM CMMS Software
TeroTAM
 
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire Unlocking the Future of Tech Talent with AI-Powered Hiring Solution...
GirikHire
 
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdfSecure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Secure and Simplify IT Management with ManageEngine Endpoint Central.pdf
Northwind Technologies
 
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdfHow a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
How a Staff Augmentation Company IN USA Powers Flutter App Breakthroughs.pdf
mary rojas
 
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdfBoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
Ortus Solutions, Corp
 
AI Alternative - Discover the best AI tools and their alternatives
AI Alternative - Discover the best AI tools and their alternativesAI Alternative - Discover the best AI tools and their alternatives
AI Alternative - Discover the best AI tools and their alternatives
AI Alternative
 
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjaraswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
aswjkdwelhjdfshlfjkhewljhfljawerhwjarhwjkahrjar
muhammadalikhanalikh1
 
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdfHow to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
QuickBooks Training
 
zOS CommServer support for the Network Express feature on z17
zOS CommServer support for the Network Express feature on z17zOS CommServer support for the Network Express feature on z17
zOS CommServer support for the Network Express feature on z17
zOSCommserver
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
iOS Developer Resume 2025 | Pramod Kumar
iOS Developer Resume 2025 | Pramod KumariOS Developer Resume 2025 | Pramod Kumar
iOS Developer Resume 2025 | Pramod Kumar
Pramod Kumar
 
Techdebt handling with cleancode focus and as risk taker
Techdebt handling with cleancode focus and as risk takerTechdebt handling with cleancode focus and as risk taker
Techdebt handling with cleancode focus and as risk taker
RajaNagendraKumar
 
Software Risk and Quality management.pptx
Software Risk and Quality management.pptxSoftware Risk and Quality management.pptx
Software Risk and Quality management.pptx
HassanBangash9
 
Marketing And Sales Software Services.pptx
Marketing And Sales Software Services.pptxMarketing And Sales Software Services.pptx
Marketing And Sales Software Services.pptx
julia smits
 
Boost Student Engagement with Smart Attendance Software for Schools
Boost Student Engagement with Smart Attendance Software for SchoolsBoost Student Engagement with Smart Attendance Software for Schools
Boost Student Engagement with Smart Attendance Software for Schools
Visitu
 
Agentic AI Desgin Principles in five slides.pptx
Agentic AI Desgin Principles in five slides.pptxAgentic AI Desgin Principles in five slides.pptx
Agentic AI Desgin Principles in five slides.pptx
MOSIUOA WESI
 

Python Versions and Dependencies Made Easy

  • 1. Sebastian Witowski Python Versions and Dependencies Made Easy
  • 2. Sebastian Witowski Python consultant, freelancer, and trainer @SebaWitowski switowski.com
  • 3. Problem with (Python) projects @SebaWitowski switowski.com
  • 4. Problem with (Python) projects Stuck in the 90s Over-engineered @SebaWitowski switowski.com
  • 5. Problem with (Python) projects Over-engineered • Too many shiny new tools from HackerNews • Those tools gets abandoned • You spend too much time replacing old tools with new ones Stuck in the 90s @SebaWitowski switowski.com
  • 6. Problem with (Python) projects Over-engineered • Too many shiny new tools from HackerNews • Those tools gets abandoned • You spend too much time replacing old tools with new ones Stuck in the 90s • Everything managed with Bash scripts • You have to maintain Bash scripts or some other scripts (as a Python developer) @SebaWitowski switowski.com
  • 7. How about a middle ground? @SebaWitowski switowski.com
  • 8. What will we talk about? • pyenv - installing different Python versions on your computer @SebaWitowski switowski.com
  • 9. What will we talk about? • pyenv - installing different Python versions on your computer • venv - isolating dependencies of your projects @SebaWitowski switowski.com
  • 10. What will we talk about? • pyenv - installing different Python versions on your computer • venv - isolating dependencies of your projects • pipx - installing global packages @SebaWitowski switowski.com
  • 11. What will we talk about? • pyenv - installing different Python versions on your computer • venv - isolating dependencies of your projects • pipx - installing global packages • pip-tools - dependency pinning @SebaWitowski switowski.com
  • 14. • Python version preinstalled on your OS is called “system Python” System Python @SebaWitowski switowski.com
  • 15. • Python version preinstalled on your OS is called “system Python” • Please, don’t use it System Python @SebaWitowski switowski.com
  • 16. • Python version preinstalled on your OS is called “system Python” • Please, don’t use it • And don’t update it (you might break your OS)! System Python @SebaWitowski switowski.com
  • 17. How to install a new Python version? @SebaWitowski switowski.com
  • 18. • Use an installer from python.org How to install a new Python version? @SebaWitowski switowski.com
  • 19. • Use an installer from python.org • Use your package manager How to install a new Python version? @SebaWitowski switowski.com
  • 20. • Use an installer from python.org • Use your package manager • Compile it from the source files How to install a new Python version? @SebaWitowski switowski.com
  • 21. Or you can use pyenv! https://github.com/pyenv/pyenv @SebaWitowski switowski.com
  • 22. Or pyenv-win for Windows https://github.com/pyenv-win/pyenv-win @SebaWitowski switowski.com
  • 25. Using pyenv 1. Find Python version to install $ pyenv install --list Available versions: 2.1.3 2.2.3 2.3.7 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 ... ... 3.9.0 3.9-dev 3.10-dev activepython-2.7.14 activepython-3.5.4 activepython-3.6.0 anaconda-1.4.0 anaconda-1.5.0 anaconda-1.5.1 anaconda-1.6.0 anaconda-1.6.1 anaconda-1.7.0 anaconda-1.8.0 anaconda-1.9.0 ... ... miniconda3-4.7.12 pypy-c-jit-latest pypy-c-nojit-latest pypy-dev pypy-stm-2.3 pypy-stm-2.5.1 pypy-1.5-src pypy-1.5 pypy-1.6 pypy-1.7 pypy-1.8 pypy-1.9 pypy-2.0-src pypy-2.0 ... ... pypy3.6-7.3.0 pypy3.6-7.3.1-src pypy3.6-7.3.1 pyston-0.5.1 pyston-0.6.0 pyston-0.6.1 stackless-dev stackless-2.7-dev stackless-2.7.2 stackless-2.7.3 stackless-2.7.4 stackless-2.7.5 stackless-2.7.6 ... @SebaWitowski switowski.com
  • 26. Using pyenv 1. Find Python version to install 2. Install it $ pyenv install 3.9.0 ... # Wait for a few minutes ... # Done! @SebaWitowski switowski.com
  • 27. Using pyenv 1. Find Python version to install 2. Install it 3. Check if it’s installed correctly $ pyenv versions * system 3.9.0 @SebaWitowski switowski.com
  • 28. Using pyenv 1. Find Python version to install 2. Install it 3. Check if it’s installed correctly 4. Start using this version $ pyenv global 3.9.0 # or $ pyenv local 3.9.0 # or $ pyenv shell 3.9.0 @SebaWitowski switowski.com
  • 29. 3 levels of pyenv • pyenv global 3.9.0 - changes the global Python version on your computer @SebaWitowski switowski.com
  • 30. 3 levels of pyenv • pyenv global 3.9.0 - changes the global Python version on your computer • pyenv local 3.9.0 - changes Python version for the current folder and all the sub-folders @SebaWitowski switowski.com
  • 31. 3 levels of pyenv • pyenv global 3.9.0 - changes the global Python version on your computer • pyenv local 3.9.0 - changes Python version for the current folder and all the sub-folders # projectA $ pyenv local 3.9.0 # projectB $ pyenv local 3.6.0 @SebaWitowski switowski.com
  • 32. 3 levels of pyenv • pyenv global 3.9.0 - changes the global Python version on your computer • pyenv local 3.9.0 - changes Python version for the current folder and all the sub-folders • pyenv shell 2.7.18 - changes Python version for the current shell session @SebaWitowski switowski.com
  • 33. Problem with pip You can only have one version of a given package installed! @SebaWitowski switowski.com
  • 34. $ pip install Django ... Django 3.0 installed! Problem with pip @SebaWitowski switowski.com
  • 35. Problem with pip $ pip install Django==2.2 ... ... ... Django 2.2 installed! @SebaWitowski switowski.com
  • 36. $ pip install Django==2.2 ... Django==3.0 uninstalled! ... Django 2.2 installed! Problem with pip @SebaWitowski switowski.com
  • 37. # .../lib/python3.9/site-packages $ ls -al ... drwxr-xr-x 22 switowski 704 Oct 30 12:41 django/ drwxr-xr-x 12 switowski 384 Oct 30 12:41 django_redis/ drwxr-xr-x 16 switowski 512 Sep 28 17:58 docutils/ ... Problem with pip @SebaWitowski switowski.com
  • 38. # .../lib/python3.9/site-packages $ ls -al ... drwxr-xr-x 22 switowski 704 Oct 30 12:41 django/ drwxr-xr-x 12 switowski 384 Oct 30 12:41 django_redis/ drwxr-xr-x 16 switowski 512 Sep 28 17:58 docutils/ ... Problem with pip @SebaWitowski switowski.com
  • 39. Virtual environment If pip installs every package in the same folder, why can’t we tell it to temporarily install them in a different folder? @SebaWitowski switowski.com
  • 40. Virtual environment If pip installs every package in the same folder, why can’t we tell it to temporarily install them in a different folder? Virtual environment: • Creates a special folder with Python binaries • Tells pip to install new packages to that folder • Tells Python to use packages from that folder @SebaWitowski switowski.com
  • 41. Using virtual environments 1. Create new virtual environment $ python -m venv .venv @SebaWitowski switowski.com
  • 42. Using virtual environments 1. Create new virtual environment 2. Activate it $ source .venv/bin/activate @SebaWitowski switowski.com
  • 43. Using virtual environments 1. Create new virtual environment 2. Activate it $ source .venv/bin/activate # Your prompt should change: (venv) $ @SebaWitowski switowski.com
  • 44. Using virtual environments 1. Create new virtual environment 2. Activate it 3. Work on your Python project (install packages, run Python) (venv) $ pip install Django==2.2 ... (venv) $ python manage.py runserver @SebaWitowski switowski.com
  • 45. Using virtual environments 1. Create new virtual environment 2. Activate it 3. Work on your Python project (install packages, run Python) 4. Deactivate virtual environment to stop using it (venv) $ deactivate $ @SebaWitowski switowski.com
  • 46. Typical workflow # Inside Django 3 project folder $ python -m venv django3-app $ source django3-app/bin/activate $ pip install django==3.0 # Inside Django 2 project folder $ python -m venv django2-app $ source django2-app/bin/activate $ pip install django==2.2 @SebaWitowski switowski.com
  • 48. virtualenvwrapper virtualenvwrapper stores all virtual environments in: ~/.virtualenvs/ @SebaWitowski switowski.com
  • 49. virtualenvwrapper virtualenvwrapper stores all virtual environments in: ~/.virtualenvs/ $ mkvirtualenv django2-app - create a virtual environment $ workon django2-app - activate it $ lsvirtualenv - list all virtual environments $ rmvirtualenv django2-app - delete a virtual environment @SebaWitowski switowski.com
  • 51. Global Python packages • Some tools should be installed globally (black, flake8, virtualenvwrapper) @SebaWitowski switowski.com
  • 52. Global Python packages • Some tools should be installed globally (black, flake8, virtualenvwrapper) • But if they require different versions of the same dependency, one of them will break @SebaWitowski switowski.com
  • 53. Global Python packages • Some tools should be installed globally (black, flake8, virtualenvwrapper) • But if they require different versions of the same dependency, one of them will break • Installing global tools into separate virtual environments is a hassle (you have to activate each virtual environment to use that tool) @SebaWitowski switowski.com
  • 54. pipx - global packages in separate environments https://github.com/pipxproject/pipx @SebaWitowski switowski.com
  • 55. pipx in action 1. Install “black” package $ pipx install black installed package black 20.8b1, Python 3.8.5 These apps are now globally available - black - black-primer - blackd done! ✨ 🌟 ✨ @SebaWitowski switowski.com
  • 56. pipx in action 1. Install “black” package 2. Use black $ black hello_world.py reformatted hello_world.py All done! ✨ 🍰 ✨ 1 file reformatted. @SebaWitowski switowski.com
  • 57. pipx in action 1. Install “black” package 2. Use black 3. “black” installed in a virtual env will shadow the global one # Inside a virtual environment (venv) $ black --version black, version 19.3b0 # Outside of a virtual environment $ black --version black, version 20.8b1 @SebaWitowski switowski.com
  • 58. pipx commands $ pipx list - list all installed packages $ pipx uninstall <package> - uninstall package $ pipx upgrade-all - upgrade all packages $ pipx inject pytest pytest-cov - install pytest-cov inside pytest virtual env @SebaWitowski switowski.com
  • 59. Dependencies in your project @SebaWitowski switowski.com
  • 60. Dependencies in your project # requirements.txt Django django-redis pytest @SebaWitowski switowski.com
  • 61. Dependencies in your project # requirements.txt Django django-redis pytest $ pip install -r requirements.txt ... Successfully installed Django-2.2, ... @SebaWitowski switowski.com
  • 62. Dependencies in your project # requirements.txt Django django-redis pytest $ pip install -r requirements.txt ... Successfully installed Django-2.2, ... $ pip install -r requirements.txt ... Successfully installed Django-3.0, ... One month later…
  • 63. Dependencies in your project # requirements.txt Django django-redis pytest $ pip install -r requirements.txt ... Successfully installed Django-2.2, ... $ pip install -r requirements.txt ... Successfully installed Django-3.0, ... One month later…
  • 64. Dependencies in your project # requirements.txt Django>=2.2,<3.0 django-redis==4.12.0 pytest==5.* Dependency pinning: @SebaWitowski switowski.com
  • 65. Dependencies in your project Always pin dependencies on production servers! @SebaWitowski switowski.com
  • 66. Dependencies in your project Always pin dependencies on production servers! And their sub-dependencies (3rd party packages)! @SebaWitowski switowski.com
  • 67. Dependencies in your project Always pin dependencies on production servers! And their sub-dependencies (3rd party packages)! And don’t forget to update packages regularly! @SebaWitowski switowski.com
  • 68. Dependencies in your project Always pin dependencies on production servers! And their sub-dependencies (3rd party packages)! And don’t forget to update packages regularly! That’s a lot of work! @SebaWitowski switowski.com
  • 69. Pipenv and Poetry to the rescue!
  • 70. But do you really need them? @SebaWitowski switowski.com
  • 71. But do you really need them? • What if they stop working? @SebaWitowski switowski.com
  • 72. But do you really need them? • What if they stop working? • What if they get discontinued? @SebaWitowski switowski.com
  • 73. But do you really need them? • What if they stop working? • What if they get discontinued? • Do you really use ALL their features? @SebaWitowski switowski.com
  • 74. Pipenv and Poetry are great @SebaWitowski switowski.com
  • 75. But sometimes a simpler tool is enough Pipenv and Poetry are great @SebaWitowski switowski.com
  • 76. But sometimes a simpler tool is enough Pipenv and Poetry are great https://github.com/jazzband/pip-tools @SebaWitowski switowski.com
  • 78. pip-compile # requirements.in Django>=2.2>,<3.0 pytest # requirements.txt # # This file is autogenerated by pip-compile # To update, run: # # pip-compile requirements.in # attrs==20.2.0 # via pytest django==2.2.17 # via -r requirements.in importlib-metadata==2.0.0 # via pluggy, pytest iniconfig==1.1.1 # via pytest packaging==20.4 # via pytest pluggy==0.13.1 # via pytest py==1.9.0 # via pytest pyparsing==2.4.7 # via packaging pytest==6.1.2 # via -r requirements.in pytz==2020.4 # via django six==1.15.0 # via packaging sqlparse==0.4.1 # via django toml==0.10.2 # via pytest zipp==3.4.0 # via importlib-metadata $ pip-compile requirements.in
  • 79. pip-compile # requirements.txt # # This file is autogenerated by pip-compile # To update, run: # # pip-compile requirements.in # attrs==20.2.0 # via pytest django==2.2.17 # via -r requirements.in importlib-metadata==2.0.0 # via pluggy, pytest iniconfig==1.1.1 # via pytest packaging==20.4 # via pytest pluggy==0.13.1 # via pytest py==1.9.0 # via pytest pyparsing==2.4.7 # via packaging pytest==6.1.2 # via -r requirements.in pytz==2020.4 # via django six==1.15.0 # via packaging sqlparse==0.4.1 # via django toml==0.10.2 # via pytest zipp==3.4.0 # via importlib-metadata @SebaWitowski switowski.com
  • 80. pip-compile # requirements.txt # # This file is autogenerated by pip-compile # To update, run: # # pip-compile requirements.in # attrs==20.2.0 # via pytest django==2.2.17 # via -r requirements.in importlib-metadata==2.0.0 # via pluggy, pytest iniconfig==1.1.1 # via pytest packaging==20.4 # via pytest pluggy==0.13.1 # via pytest py==1.9.0 # via pytest pyparsing==2.4.7 # via packaging pytest==6.1.2 # via -r requirements.in pytz==2020.4 # via django six==1.15.0 # via packaging sqlparse==0.4.1 # via django toml==0.10.2 # via pytest zipp==3.4.0 # via importlib-metadata @SebaWitowski switowski.com
  • 81. pip-compile # requirements.txt # # This file is autogenerated by pip-compile # To update, run: # # pip-compile requirements.in # attrs==20.2.0 # via pytest django==2.2.17 # via -r requirements.in importlib-metadata==2.0.0 # via pluggy, pytest iniconfig==1.1.1 # via pytest packaging==20.4 # via pytest pluggy==0.13.1 # via pytest py==1.9.0 # via pytest pyparsing==2.4.7 # via packaging pytest==6.1.2 # via -r requirements.in pytz==2020.4 # via django six==1.15.0 # via packaging sqlparse==0.4.1 # via django toml==0.10.2 # via pytest zipp==3.4.0 # via importlib-metadata @SebaWitowski switowski.com
  • 82. pip-compile # requirements.txt # # This file is autogenerated by pip-compile # To update, run: # # pip-compile requirements.in # attrs==20.2.0 # via pytest django==2.2.17 # via -r requirements.in importlib-metadata==2.0.0 # via pluggy, pytest iniconfig==1.1.1 # via pytest packaging==20.4 # via pytest pluggy==0.13.1 # via pytest py==1.9.0 # via pytest pyparsing==2.4.7 # via packaging pytest==6.1.2 # via -r requirements.in pytz==2020.4 # via django six==1.15.0 # via packaging sqlparse==0.4.1 # via django toml==0.10.2 # via pytest zipp==3.4.0 # via importlib-metadata @SebaWitowski switowski.com
  • 83. pip-compile # requirements.txt # # This file is autogenerated by pip-compile # To update, run: # # pip-compile requirements.in # attrs==20.2.0 # via pytest django==2.2.17 # via -r requirements.in importlib-metadata==2.0.0 # via pluggy, pytest iniconfig==1.1.1 # via pytest packaging==20.4 # via pytest pluggy==0.13.1 # via pytest py==1.9.0 # via pytest pyparsing==2.4.7 # via packaging pytest==6.1.2 # via -r requirements.in pytz==2020.4 # via django six==1.15.0 # via packaging sqlparse==0.4.1 # via django toml==0.10.2 # via pytest zipp==3.4.0 # via importlib-metadata @SebaWitowski switowski.com
  • 84. pip-compile Now, run: $ pip install -r requirements.txt @SebaWitowski switowski.com
  • 85. pip-compile Now, run: $ pip install -r requirements.txt Need to update dependencies? $ pip-compile requirements.in @SebaWitowski switowski.com
  • 86. pip-compile Make pip-compile part of your CI @SebaWitowski switowski.com
  • 87. pip-compile Make pip-compile part of your CI If something breaks, pin that package in requirements.in @SebaWitowski switowski.com
  • 91. Summary • Use pyenv to install/update Python versions @SebaWitowski switowski.com
  • 92. Summary • Use pyenv to install/update Python versions • Use venv/virtualenvwrapper to isolate dependencies of your projects @SebaWitowski switowski.com
  • 93. Summary • Use pyenv to install/update Python versions • Use venv/virtualenvwrapper to isolate dependencies of your projects • Use pipx to install global tools @SebaWitowski switowski.com
  • 94. Summary • Use pyenv to install/update Python versions • Use venv/virtualenvwrapper to isolate dependencies of your projects • Use pipx to install global tools • Consider pip-tools when you just need to pin dependencies @SebaWitowski switowski.com
  • 95. Where to go next? @SebaWitowski switowski.com
  • 96. Where to go next? “Modern Python Projects” workshop (part of this conference) @SebaWitowski switowski.com
  • 97. Where to go next? “Modern Python Projects” online course https://modernpythonprojects.com/ @SebaWitowski switowski.com