Use `Python -m Pip`
91–100 of 141 posts
Re: Use `Python -m Pip`
#92Earlier 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 >…
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 freezeRe: Use `Python -m Pip`
#93Earlier 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).
Re: Use `Python -m Pip`
#94Earlier 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?
Re: Use `Python -m Pip`
#95I 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…
- 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`
#96It could not be more simple.
Re: Use `Python -m Pip`
#97Python 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.
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`
#98Python 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…
I use pyenv+pipenv (@linux) and are mostly happy with it.
Re: Use `Python -m Pip`
#99Python 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…