News for hackers. Stuff that matters.

Ask HN: 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.

( 11 comments | 7 points | on HN )
Re:Ask HN: Proper way to set up Python dev environment on Ub... by ddavis on Monday August 10, 2020 @08:20PM (#24115846)
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

Re:Ask HN: Proper way to set up Python dev environment on Ub... by sigjuice on Monday August 10, 2020 @09:32PM (#24116314)
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.
Re:Ask HN: Proper way to set up Python dev environment on Ub... by dhruvkar on Monday August 10, 2020 @08:49PM (#24116062)
- pyenv

- pyenv-virtualenv

- poetry

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

Re:Ask HN: Proper way to set up Python dev environment on Ub... by Maha-pudma on Tuesday August 11, 2020 @06:15PM (#24126656)
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?

Re:Ask HN: Proper way to set up Python dev environment on Ub... by tcbasche on Wednesday August 12, 2020 @07:34PM (#24138344)
I think anaconda is mostly used in the data science community, so if that's the kind of work you'll be doing it's great for that (notebooks and such).

For everything else I think virtualenv is fine, bit unintuitive but fit for purpose (more or less).

Re:Ask HN: Proper way to set up Python dev environment on Ub... by wwarner on Monday August 10, 2020 @08:24PM (#24115874)
Docker will save you a lot of headaches https://hub.docker.com/_/python
Re:Ask HN: Proper way to set up Python dev environment on Ub... by ralston3 on Tuesday August 11, 2020 @12:06PM (#24121913)
Python3.8 , then use virtual envs with “python -m venv ...”
Re:Ask HN: Proper way to set up Python dev environment on Ub... by minhoryang on Tuesday August 11, 2020 @10:45AM (#24120774)
anyenv + pyenv + pyenv-virtaulenv + poetry
Re:Ask HN: Proper way to set up Python dev environment on Ub... by scott31 on Monday August 10, 2020 @11:45PM (#24116986)
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
Re:Ask HN: Proper way to set up Python dev environment on Ub... by tcbasche on Wednesday August 12, 2020 @07:35PM (#24138352)
Ah yes, Rust - that easy-to-learn world-renowned language for data science, machine learning and web dev.
Re:Ask HN: Proper way to set up Python dev environment on Ub... by probinso on Tuesday August 11, 2020 @10:28PM (#24128045)
Gross