Live data from Hacker News

My Python Development Environment, 2018 Edition

jacobian.org

21–30 of 224 posts

Re: My Python Development Environment, 2018 Edition

#22
post #16
post #13

Earlier quoted context omitted.

As a Python developer, I just stay with pip and virtualenv, but I share the smh/wtf sentiment here. The data science folks enjoy conda but I don't see that being useful to me anywhere else. I feel like every other year someone will invent a new pip env . pyvenv (see comment section, edited) is now deprecated and venv is recommended (shipped as part of Python 3.6 installation) is another confusion. Lest not forget the…

Conda is especially useful if you want to use scientific packages on Windows.

Yeah, I use pip + virtualenv on most machines (and have for years), but conda is the only one that actually seems to "just work" on Windows.

Re: My Python Development Environment, 2018 Edition

#24

>Why? pipenv handles dependency- and virtual-environment-management in a way that’s very intuitive (to me), and fits perfectly with my desired workflow. Why specifically do you use it instead of virtualenv (+virtualenvwrapper)?

I was recently explaining this here — you still end up with a virtualenv so it's not a difference in capabilities but rather ease of use:

1. It transparently creates the virtualenv for you

2. The pipfile format handles dependencies and version locking (including hashes of packages), including updates. That means that the versions won't change without your knowledge but upgrading to the latest versions of everything is simply running "pipenv update" to have the virtualenv completely rebuilt (i.e. you'll never forget to add a dependency to a requirements file) and the lock file updated so the next time you push your code the same versions you tested are certain to be used.

3. It'll automatically load the .env file for every command – i.e. your project can have "DJANGO_SETTINGS_MODULE=myproject.site_settings" in that file and you will never need to spend time talking about it in the future.

4. It separates regular and developer dependencies so you don't install as much on servers

5. "pipenv check" will let you know whether any of the versions of any of the packages installed have known security vulnerabilities

6. Pipfile also includes the version of the Python interpreter so e.g. your Python 2 project will seamlessly stay on 2.7 until you upgrade even if your system default python becomes 3.

None of this is something you couldn't do before but it's just easier. Every time a Python point release happens you have to rebuild a virtualenv and now it takes 5 seconds and no thought.

Re: My Python Development Environment, 2018 Edition

#26

I haven't had to write python in awhile but are there reasons to use virtualenv etc. instead of a docker container?

Less of a pain in the ass for rapid iteration, zero overhead, fewer dependencies = less complexity.

Virtualenv is literally a set of shims in your $PATH and some tooling to manage those sets. Pyenv is the same thing, but extends the concept out to your actual Python interpreter and lets you rapidly switch between them.

Re: My Python Development Environment, 2018 Edition

#27
I’m using Anaconda because it was recommended in a step by step tutorial for playing with deep learning.

What would be involved in removing it from my system and moving instead to this set of tools?

Not necessarily looking for s step by step answer, just for general suggestions.

My guess is: find out which python the deep learning tools are using, remove Anaconda, and reinstall the python version needed, using the tools from this post. I’ll need to read up on the tools too. Any pitfalls with this approach?

Re: My Python Development Environment, 2018 Edition

#28
post #8

Is there a command needed in pipenv like the one needed in virtualenv? eg. > source env/bin/activate How does one activate one environment over another? Why is pipsi a separate thing?

pyenv/pipenv are for your development. pipsi is for installing Python tools/applications that you just want to use, like apt/yum.

Re: My Python Development Environment, 2018 Edition

#29
post #3

Pyenv looks great! Sad I didn't know about this sooner, though I do have the luxury of using mostly one version of Python and have only confused it for the system Python once or twice.

Pyenv is great. On our Macs we've had zero issues installing older, specific versions of Python, every time. Highly recommended. (Getting it working properly with zsh was a bit frustrating, but that's my own fault.)

Curious here... why would you use it over just venv (assuming python3)?
Post reply on HN