5 ms·
While this is all nice, I have yet to find a package system that is as straight forward to use as NPM. Don't get me wrong, I love Python and I'm not so much a
by vog 10y ago
While this is all nice, I have yet to find a package system that is as straight forward to use as NPM.
Don't get me wrong, I love Python and I'm not so much a fan of NodeJS, as Python is so much better designed than JavaScript, even in time of ES6. But their NPM is really well designed. NPM alone gives NodeJS a competitve advantage over many other popular languages including Ruby (Gem) and Python (PIP).
For example, why does Python packaging need such a complicated bootstrapping process? Install ensure_pip, then the real pip, and on top of that virtualenv. NodeJS just ships with NPM. Done.
Any why do we need to create and manage a "virtualenv"? Why do you have to go through extra hassle just to avoid global installs? NPM just creates a local sub directory node_modules and automatically installs and removes from that. Global installs happen only if you really want it to (npm -g). But you usually don't.
The only central place at NPM is the package cache so it doesn't download things twice if you have two separate projects with similar dependencies. In the Python/PIP world, everything is central and even today you still have to accept extra hassle to get a sane, local setup.
- jessaustin 10y agoIt almost seems, based on TFA's risibly misguided "dumb idea" link to npmjs.com, that the author thinks python's story is better than node/npm's. It's called "separation of concerns", kids, and it's a good thing, that one part of a script doesn't have to worry about what a different part of the script is doing. The fact python never got it to work correctly is python's problem; node handled it from the beginning.
- swsieber 10y agoNPM is also a pain in the neck - I've had to wipe out the node_modules folder many times because it got in a bad state when adding dependencies. Other than that, I agree.
- transcranial 10y agoIn my experience, the only time this happens is with `npm uninstall`. If you only `npm install` stuff forever, node_modules seems pretty stable. Disk usage, however, is another matter.
- beagle3 10y agoconda is way better than plain pip (although it is still compatible with it), and possibly better than NPM. It's just not well known enough yet.
- zo1 10y agoI have yet to come across a scenario where installing a python library as global ended up being an issue in the python ecosystem. You either need it, or you don't. Short of some contrived scenario where a piece of code is not able to utilize a certain package's latest code and you have to juggle two different versions of that package. If I had something like that, I'd fix the code, not juggle old package versions or install all dependencies in my project's sub-folder. > "For example, why does Python packaging need such a complicated bootstrapping process? Install ensure_pip, then the real pip, and on top of that virtualenv." It's not that complicated: sudo apt-get install python-pip python-dev build-essential sudo pip install --upgrade pip Then you can install any python package to your heart's content with: pip install PACKAGE You don't need virtualenv, nor do you need ensurepip. >"In the Python/PIP world, everything is central and even today you still have to accept extra hassle to get a sane, local setup." I think you may be coming at it from a javascript perspective where you expect it to work according to the way you're used to it working with Node/NPM. I have absolutely no hassle installing anything in the python/pip ecosystem. Except maybe MySQL and OpenCV, I'll grant you that. But those are separate discussions as they require external dependencies outside of python's packaging.
- Eridrus 10y agoI've run into several issues with global installs because the Ubuntu maintainers have decided to make changes to libraries I want to use.
- gcr 10y agoAnother example happens when compiling scientific libraries that require C extensions. I've seen disagreements about which versions of libraries to link against. For example, I've run into issues when installing scikit-learn via pip because it linked against the Numpy version in /usr/lib rather than the correct Numpy in my virtualenv.
- rlpb 10y agoUbuntu maintainer here. Can you be more specific, please? I'd like to understand if there was a general reason or if we're doing something that we should not be doing.
- Leynos 10y agoAs long as you're using Python 3, pip and pyvenv are bundled with Python. Pip is also included with Python 2.7.9 and later for Python 2 users.
- yladiz 10y agoHaving pip installed by default is really nice, so that it consolidates people to use pip unless they have specific use cases e.g. Anaconda users. However, pyvenv/virtualenv isn't that great for the reasons the poster mentions, specifically that you have to set up something instead of just installing in a local folder and referencing that. I do think that pip is more mature and in some ways is better than npm, but in the respect of where it installs modules, it's definitely behind (I do realize that this is also a Python issue wrt where it references modules, but installing modules global by default is a pip issue. At least they're working on doing more local installations by default[0]). I shouldn't have to worry about where my modules are installed in general, and if I'm working on multiple projects with different package versions, I shouldn't have to think about virtualenvs because if I mess up and forget to activate it, it may or may not give me strange errors during various parts of development. 0: https://github.com/pypa/pip/issues/1668 https://github.com/pypa/pip/issues/1668
- wlesieutre 10y agoI've also found venv to be a pain if you're trying to set up your editor to execute scripts in the virtual environment. Npm project? Build and run. Python project? Figure out how to make VS Code activate the environment first.
- yladiz 10y agoThat is one of the things I really appreciate about Node/npm. Drive space isn't a concern particularly, since packages aren't gigabytes in size, so having them installed locally is fine. The biggest gripe is you have to include `node_modules/` in your `.gitignore`.
- spdionis 10y agoComposer in PHP-world works even better than NPM, while being similiar in some ways.
- AgentME 10y agoI've always argued that npm is nodejs's killer feature. Semver is suggested and used almost everywhere. Setting up the development environment for almost any project is just `npm install` from within its directory. Dependency hell isn't a show-stopping issue: it's perfectly fine for libraries A and B to have sub-dependencies and to depend on different versions of C. No longer do I have to wrestle with things when I try to install a project that relies on a different version of what I already had installed on my system. (Sure, there's some gains to be had to updating packages to consistently use the latest version of C, but when we're talking about libraries on the order of kilobytes, that really shouldn't be a blocker issue stopping something from working.)
- p0nce 10y agoDUB for dlang is heavily inspired by NPM.
- eivarv 10y agoI'd say Conda [1] is as straight forward to use as NPM, and handles virtual environments (better than virtualenv) as well. I don't really see the issue with creating a virtual environment in the case of specific dependencies, and otherwise dealing directly with the global environment (which really isn't that different from e.g. NPM and JS, when you think about it). [1]: https://github.com/conda/conda https://github.com/conda/conda