top | item 32806932

(no title)

julienpalard | 3 years ago

I don't see the dumpster fire here:

$ python -m pip install west

That's it, no venv, no sudo.

pip will install it in ~/.local/ so you'll need a:

    PATH="$PATH:$HOME/.local/bin"
to get it to your path.

discuss

order

nicoco|3 years ago

On my debian stable, if I want this behaviour I actually have to add `--user`.

But that's not the recommended way to install pypi packages you want to use, with debian at least. This may install dependencies that will break (for your user) some debian packages depending on other versions of said dependencies. The easy way to go is `pipx install west`.

EDIT: --user is not necessary anymore. I think this does not alter the validity of the rest of my comment.

rcarmo|3 years ago

Actually, you shouldn’t need to add that flag, AFAIK it’s been the default for a while for non-root users. But both Debian and Ubuntu tend to package their Pythons to rely on .deb packages and have been somewhat inconsistent over the years.

Does it try to install packages in your system paths and fails due to lack of permissions?

PaulHoule|3 years ago

   pip —user
is suicide. You can be doing everything right, using venv’s, conda and all that, install one package in a user directory and blam! You just broke every Python you use because that package is installed in all your environments.

It’s a bad idea right up there with Linux distros having python2, python3, python3.1, puthon3.2, python3.3, …. They give up the ease of use of a command line application where you can tell people what to type for the mind numbing complexity of a GUI application where it takes a 1500 page book to explain how to do anything in Microsoft Word because now you can’t tell people what to type to run and install things.

randyrand|3 years ago

why use -m?

viraptor|3 years ago

It ensures you're installing into environment using your current python. Useful in case the op already has a messed up environment where default pip doesn't use default python.

julienpalard|3 years ago

It's a good habit which ensures pip runs with the same interpreter as your `python` command.

One example (but there's many): On Windows a `pip install --upgrade pip` can't work as the OS would lock the `pip` executable, while a `python -m pip install --upgrade pip` works as the OS would lock python instead.

I also encontered environments (CI runners, things like this) with `python` and pip installed, installed but no `pip` shortcut.

More: https://snarky.ca/why-you-should-use-python-m-pip/