git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why do I need to use pip3 but not pip


? Hello,

It depends on the operating system. For example on Ubuntu, the default
python version is still 2.7. When you install both python2.7 and python3
on a system, then usually the "pip" will be a symlink to pip version 2
or 3. The default python interpreter can be different on different systems.

The most portable way to run pip with a given version (AFAIK) is to use
"python -m pip" instead of "pip".

E.g.:

python3 -m pip install PACKAGE_NAME

However, there is still a problem when you have multiple python versions
on the same machine. For example, python3.6 and python3.7. On those
systems, python3 will be a symlink to the default one.

For example:

$ which python
/usr/bin/python
$ ls -lah /usr/bin/python

lrwxrwxrwx 1 root root 9 apr?? 16? 2018 /usr/bin/python -> python2.7

$ which python3?????????
/usr/bin/python3
$ ls -lah /usr/bin/python3

lrwxrwxrwx 1 root root 9 oct?? 25 13:11 /usr/bin/python3 -> python3.6

Regards,

?? Laszlo


2019. 03. 30. 9:20 keltez?ssel, Arup Rakshit ?rta:
> Hi,
>
> When I read this https://pip.pypa.io/en/stable/installing/ it says I
> have the pip installed when I installed the python from official doc.
> But when I run the `pip` command from shell, I get error, but pip3 works.
>
> ~/python_playground ? pip --version
>
> zsh: command not found: pip
>
> ~/python_playground ?
> ? pip3 --version
>
> pip 18.1 from
> /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip
> (python 3.7)
>
> Do I always need to install using pip3 program then?
>
>
> Thanks,
>
> Arup Rakshit
> ar at zeit.io
>
>
>