HACKER Q&A
📣 young_unixer

Proper way to set up Python dev environment on Ubuntu?


Do you use venv, virtualenv, virtualenvwrapper, or pipenv?

Do you install pip from the Ubuntu repos or from "https://bootstrap.pypa.io/get-pip.py" ?

Every time I try to set up a Python environment I end up installing pip in 4 different ways and I don't know which version to use and it's a whole mess.


  👤 ddavis Accepted Answer ✓
I'm a big fan of pyenv [1] with the pyenv-virtualenv extension [2]. The combination makes handling virtual environments with different Python versions incredibly easy.

[1] https://github.com/pyenv/pyenv

[2] https://github.com/pyenv/pyenv-virtualenv


👤 sigjuice
It depends on how sophisticated your needs are. I mostly run python programs of my own on a single computer. I tell the distribution-provided pip to install an upgraded pip separately (pip3 install --user -U). I install everything using pip3 install --user and under no circumstances run any pip commands as root. So far, I have not needed foo-env or docker.

👤 dhruvkar
- pyenv

- pyenv-virtualenv

- poetry

This is for macOS, but it seems pretty straightforward. I https://duncanleung.com/set-up-python-pyenv-virtualenv-poetr...


👤 Maha-pudma
Can I take in from the answers here that no one uses anaconda?

I'm only a beginner and that is what I was told to use. It has environments too. Should I be using something else?


👤 wwarner
Docker will save you a lot of headaches https://hub.docker.com/_/python

👤 ralston3
Python3.8 , then use virtual envs with “python -m venv ...”

👤 minhoryang
anyenv + pyenv + pyenv-virtaulenv + poetry

👤 scott31
This is my python setup for ubunut:

    sudo apt remove python3
    sudo apt install python2
    curl https://sh.rustup.rs -sSf | sh # Just in case you want to switch to rust later