Live data from Hacker News

Use `Python -m Pip`

snarky.ca

91–100 of 141 posts

Re: Use `Python -m Pip`

#92
post #27

Earlier quoted context omitted.

To be honest, I don't see how you can give this advice. A couple of the most popular package management systems for Python are very obviously deficient (and sigh, these are usually the ones I get stuck working with, due to outside constraints). A classic example is version pinning. Rust has Cargo.lock, Ruby has Gemfile.lock. Python? It depends on which one of the multitude of options you pick. But at least a couple o…

"pip freeze" generates a versioned list of packages to install in the same format as requirements.txt -- in this example below i've called it versions.txt. I have a bash wrapper "bin/venv-create" which essentially does this python3 -m venv .venv/ if [[ -f versions.txt ]] && [[ versions.txt -nt requirements.txt ]]; then pip install --requirement versions.txt else pip install --requirement requirements.txt pip freeze >…

`pip freeze` doesn't generate hashes, so you can't be sure that the package contents haven't actually changed but maintained the same version string.

Also, `pip freeze` doesn't include platform-specific dependencies for other platforms. So if you run the following on linux and again on macos, you'll get different results because `ipython` depends on `appnope` only when running on macos.

  python -m venv env && env/bin/pip install ipython==8.4.0 --quiet && env/bin/pip freeze

Re: Use `Python -m Pip`

#93
post #45

Earlier quoted context omitted.

On unixy systems, won't the system Python usually require root/sudo to install packages, whereas the ones in your environments will be owned by a less-privileged user? And on Windows, you may have a globally installed Python (though there is little reason to have one instead of the Py launcher), but even if you do it's not a system Python that system components are relying on.

Unfortunately the pip developers had the genius idea to add a "user install" mode which pip will default to in this situation. So if you're not root, you won't be able to mess up your system-global Python, but you can still mess up your user-global Python (deleting some ~/.local subfolders takes care of this).

Useful feature that should have existed from the beginning. If it did, the sudo mistake wouldn’t have happened.

Re: Use `Python -m Pip`

#94

Earlier quoted context omitted.

Yeah, I agree with this. I typically dockerize where appropriate to sidestep this a little, but very often rewrite everything into a more friendly language like Go if I am intending to ship software to other machines. The latter is obviously painful if I’m making heavy use of Python specific libraries that do a lot of heavy lifting like Numpy, if those features aren’t in something like GoNum.

I should also say: Unfortunately, Conda’s environment exports only work for similar OS’s. I don’t know why Python’s situation is like this, after so many years. Does docker fix all the above issues?

Yes, docker solves all these issues (because your app carries all of its environment in the image), however it is a bit cumbersome if you want to distribute your app to many unknown users. They can't just download something and run it, as Windows users are used to doing.

Re: Use `Python -m Pip`

#95

I mean, this is generally good advice, but this reads like an infomercial where they show someone struggling REALLY hard to boil water to make a pot of spaghetti, when we all know it's really not that hard. They try to make finding your pip executable sound difficult, and even more difficult would be to understand what interpreter its tied to. Except... > pip -V > # pip 19.0.3 from /usr/local/lib/python2.7/site-packa…

This. Also, the argument is a bit weird:

- always use python -m pip

- if in venv, it doesn't do any good, but do it anyway for consistency

- you should also use venv

So... Maybe just always use virtual env and then you can use just pip?

Re: Use `Python -m Pip`

#97
post #51
post #31

Python as a language is a joy to use (for small projects), however pip has soured my experience of Python so drastically that I actively avoid taking up Python projects out of knowledge - not fear, knowledge - that the setup/install process is going to be a humongous pain. In most cases I can get started more easily with Node.js/TypeScript. in b4 "use some other package manager / pipenv / virtualenv etc" - no. How ab…

Quoted post unavailable.

Probably not down-voted for that, many Python devs agree that pip is basically garbage, down-voted because there are very simple solutions to Python's distribution problems that you refuse to acknowledge.

Depending on your use case, there are various tools, but one easy set of tools that is good for anything from large production deployments down to an ML notebook environment is pyenv+poetry. Those two will, with very few commands, allow you to specify and install your environment for a project very easily and with similar ease as you might find when using nvm (similar tool to pyenv) and npm (similar tool to poetry) for a JS/TS/node/whatever project.

You got down-voted for being willfully ignorant and proud of it, basically.

Re: Use `Python -m Pip`

#98
post #31

Python as a language is a joy to use (for small projects), however pip has soured my experience of Python so drastically that I actively avoid taking up Python projects out of knowledge - not fear, knowledge - that the setup/install process is going to be a humongous pain. In most cases I can get started more easily with Node.js/TypeScript. in b4 "use some other package manager / pipenv / virtualenv etc" - no. How ab…

The issue is that there are many different ways to setup your environment. Every python dev has their own set of tools that mostly work, but sometimes break in some corner cases... and then the problems start, because searching for a solution will inevitably produce something that is almost, but not completely, applicable to your situation.

I use pyenv+pipenv (@linux) and are mostly happy with it.

Re: Use `Python -m Pip`

#99

Python is a fun language but the ecosystem around it is horrible. It's a shame. I just want to pip install like I would a package manager

I think you mean the package management rather than the ecosystem. For all its failings, the python ecosystem (for machine learning / data science in particular) is unmatched, which is why python is so popular. As a "professional" python user (who got there in a roundabout way), I'd say the biggest problem with package management is all the conflicting advice and different ways to accomplish the same thing (there are…

Could you please link to your favorite way to install python at specific version and all dependencies without have to put anything in a global place. Ideally on MacOS (since it's what I'm on most). I don't have homebrew or macports since eventually those always lead to me getting a borked system since they want everything installed globally.
Post reply on HN