Live data from Hacker News

You don't really need a virtualenv

frostming.com

51–60 of 148 posts

Re: You don't really need a virtualenv

#51

Could someone ELI7 why python is struggling so hard with dependencies and dependency management when in the Java world this is a solved problem and just works with maven, which is working so damn well it last got updated in November 2019, and the biggest fight going is whether you should use gradle as client instead of maven to access the same dependency ecosystem? I had to set up Python projects for some machine lea…

Java is a self hosted language and has very little dependency on C/C++ or something similar. Python is glue language for C/C++/Fortran/Rust/etc. projects. Most of the valuable packages in Python in fact C++ projects (like Tensorflow, Pandas, etc.). When you are talking about Python dependency management you are talking about the Cartesian product of the packages you are depending on, their dependency in terms of comp…

Compiled dependencies is indeed one of the main reasons. Another one is lack of enforced, static metadata because python started before most other languages.

Re: You don't really need a virtualenv

#52

Earlier quoted context omitted.

Python should just do what JavaScript does and install all dependencies to a project-local folder.

Not sure if JavaScript has anything that any other language or development tool should copy.

It is a mess... But you can often get a project running an awful lot quicker than in python

Re: You don't really need a virtualenv

#54

> things get tricky when it comes to nested venvs Never had such a requirement. Environments, like the interpreter itself, seem a singleton concept. I have used a Makefile that sources different Bash environment variables kept in files in etc/ within the venv to switch between, say, a Flask and a Gunicorn startup.

Yes you're using nested venvs you're really making it harder on yourself.

Way way harder on yourself.

Re: You don't really need a virtualenv

#55

Could someone ELI7 why python is struggling so hard with dependencies and dependency management when in the Java world this is a solved problem and just works with maven, which is working so damn well it last got updated in November 2019, and the biggest fight going is whether you should use gradle as client instead of maven to access the same dependency ecosystem? I had to set up Python projects for some machine lea…

I am probably in the minority, but my experience is the complete opposite. I had more trouble trying to set up a gradle project in university than I ever had with Python.

Re: You don't really need a virtualenv

#56
post #47

This was a good article and looks like an interesting project. Regardless of whether or not you choose to _deploy_ with Docker, _developing_ in Docker containers using the VS Code Remote extensions really solved all of Python's (and Javascript's) annoying packaging problems for me, with the bonus that you also get to specify any additional (non-Python) dependencies right there in the repo Dockerfile and have the deve…

I just read this https://ntietz.com/tech-blog/drawbacks-of-developing-in-cont... The author highlights some of the problems of using docker in development.

Yeah, I read that too and thought he made some good points.

I probably should have been more careful to qualify my enthusiasm above. I’m definitely not suggesting that everyone that has a Python packaging problem should go out and solve it with Docker. As with all things, there are trade-offs and you should satisfy yourself that Docker is the right tool for your particular problem before diving in.

I just wanted to highlight the fact that - as a VS Code user who has some experience with Docker and writes in a couple different languages and ecosystems - I’ve had a great experience with this modality and find that overall it simplifies my workflow.

Re: You don't really need a virtualenv

#57

Earlier quoted context omitted.

Python should just do what JavaScript does and install all dependencies to a project-local folder.

Not sure if JavaScript has anything that any other language or development tool should copy.

JavaScript's package management is significantly better than Pythons:

- There's one tool to use, and it comes pre-installed

- You don't have to deal with virtualenvs or packages from different projects conflicting.

- Native code dependencies "just work".

Re: You don't really need a virtualenv

#58
post #45

Earlier quoted context omitted.

I have the opinion that this is because "Deployment" is not a solved issue (or clearly defined and enforced) for Python. C has shared libraries and static compilation (bundling of dependencies) Java has .jar files which probably contain all your dependencies, go and Rust statically compile to something that has minimal dependencies and python has... no clue. Some packages you have to install via your package manager…

Python should just do what JavaScript does and install all dependencies to a project-local folder.

You are assuming there is a "project", but Python code with massive dependencies can (and often should) be a bare script in an arbitrary folder that runs by invoking the Python interpreter on it, without "installing" anything except missing dependencies.

Re: You don't really need a virtualenv

#59

Could someone ELI7 why python is struggling so hard with dependencies and dependency management when in the Java world this is a solved problem and just works with maven, which is working so damn well it last got updated in November 2019, and the biggest fight going is whether you should use gradle as client instead of maven to access the same dependency ecosystem? I had to set up Python projects for some machine lea…

Java is a self hosted language and has very little dependency on C/C++ or something similar. Python is glue language for C/C++/Fortran/Rust/etc. projects. Most of the valuable packages in Python in fact C++ projects (like Tensorflow, Pandas, etc.). When you are talking about Python dependency management you are talking about the Cartesian product of the packages you are depending on, their dependency in terms of comp…

> It is not hard to run into missing .h files while trying to install these dependencies.

They would be if python provided the .h files in the packages rather than expecting them to already exist on the system.

Re: You don't really need a virtualenv

#60
post #9

Earlier quoted context omitted.

He also said virtual envs install their own copy of Python. No need for that either. Coming from other languages the whole virtual env thing seems alien especially the way it messes with your shell.

A virtualenv (venv) does not install its own copy of Python. Instead, when you create the venv it puts symlinks for the calling python in the /bin directory. When you activate the venv the /bin is added to the front of your PATH so that any "python" commands use the symlink'ed version of Python corresponding to your venv.

Indeed, a virtual env is really not that exciting or complicated. Even "activating" a virtualenv is just changing your shell's PATH so it picks the virtualenv binaries, nothing else. You can also just call those binaries directly from their installed location in the env without ever having to "activate" or "workon" anything.
Post reply on HN