Hacker News new | ask | show | jobs
by xyrouter 2867 days ago
> On some Python 3 distributions, you may need to replace pip with pip3 in the command above.

Are there any distributions where the command pip just works with Python 3?

In every Python 3 installation I have used, I had to invoke it as pip3. So it seems to me that pip3 is the commonly used command and one may need to replace pip3 with pip only on some distributions.

4 comments

AFAIK you usually have pip (system default python), pip2 (corresponds to python2), and pip3 (corresponds to python3). Like others have mentioned, a few distributions have python 3 as the default python.

In later versions you can invoke pip using python -m pip install ..., which makes it more clear which python is being used.

Try `PYTHON -m MODULE` as in `python3 -m pip` if you want to make sure to use python3's pip, `python2 -m pip` for python2, `~/bin/python -m pip` for a personal python install, etc.
Arch Linux has been shipping Py3 as the default python for a long time…
I am aware of that. So has been many other distributions like Debian, Ubuntu, etc.

My point was: Which command do you normally use to install packages in Python 3? pip3 or pip?

I thought it was pip3 but the article seems to imply that using the pip command to install packages in Python 3 is common too. If this is true, which distribution ships Python 3 with pip instead of pip3 for installing packages in Python 3? Does it not conflict with pip of Python 2?

Not the parent but on Ubuntu I use:

$ python -m pip ... # Use Python 2

$ python2 -m pip ... # If you want to be sure is using Python 2

$ python3 -m pip ... # Use Python 3

$ python3 -m venv ... # Create a virtualenv with Python 3 as documented on https://docs.python.org/3/library/venv.html to "prevent any potential confusion as to which Python interpreter a virtual environment will be based on"

I know it's verbose and long to type but looks explicit to me and saved me to use the wrong version of Python several times.

If 'python' is 3, I'd expect 'pip' to be for 3, and 'pip2' for 2.
Ah! That makes a lot of sense. If Python 3 is the default, it does make sense 'pip' to be the Python 3 pip. That way 'pip' always refers to the default version.

Unfortunately in the Ubuntu and Mac world 'python' is still Python 2.7 and 'pip' refers to the Python 2 pip. Python 3 is available as 'python3' along with 'pip3'.

Yes. On Arch Linux you would use just pip. pip2 for Python 2.
I generally use pyenv and/or a virtualenv, where the python and pip aliases point to the currently active version, which is almost always 3.