pip 与 pip3 区别

pip 与 pip3 区别

  • 电脑同时有多个版本的 python 时,pip3 可以自动判别用 python3 来安装库,是为了避免同 python2 发生冲突。
  • 如果你的电脑仅仅安装了 python3,使用 pip 或者 pip3 是一样的。

安装 python3 后,会有 pip3.
pip install xxxxxx
新安装的库会放在后面这个目录下面:python2.7/site-packages

pip3 install xxxxxx
新安装的库会放在后面这个目录下面:python3.6/site-packages
如果使用 python3 执行程序,那么就不能 import python2.7/site-packages 中的库。

pip3 always operates on the Python3 environment only, as pip2 does with Python2. pip operates on whichever environment is appropriate to the context. For example if you are in a Python3 venv, pip will operate on the Python3 environment.

strong@foreverstrong:~$ which pip
/usr/local/bin/pip
strong@foreverstrong:~$ 
strong@foreverstrong:~$ which pip3
strong@foreverstrong:~$ 
strong@foreverstrong:~$ which python
/usr/bin/python
strong@foreverstrong:~$ 
strong@foreverstrong:~$ which python3
/usr/bin/python3
strong@foreverstrong:~$ 
strong@foreverstrong:~$ pip -V
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
strong@foreverstrong:~$ 
strong@foreverstrong:~$ pip3 -V
The program 'pip3' is currently not installed. You can install it by typing:
sudo apt install python3-pip
strong@foreverstrong:~$ 
strong@foreverstrong:~$ pip list
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Package                            Version    
---------------------------------- -----------
adium-theme-ubuntu                 0.3.4      
attrs                              15.2.0     
autobahn                           0.10.3     
backports-abc                      0.5        
backports.functools-lru-cache      1.4        
backports.shutil-get-terminal-size 1.0.0      
backports.weakref                  1.0rc1     
bleach                             1.5.0      
colour                             0.1.5      
configparser                       3.5.0      
cryptography                       1.2.3      
cycler                             0.10.0     
Cython                             0.28.2     
decorator                          4.1.2      
descartes                          1.1.0      
entrypoints                        0.2.3      
enum34                             1.1.6      
funcsigs                           1.0.2      
functools32                        3.2.3.post2
futures                            3.0.5      
goto                               1.0        
heatmap                            2.2.1      
hmmlearn                           0.2.0      
html5lib                           0.9999999  
idna                               2.0        
imutils                            0.4.6      
ipaddress                          1.0.16     
ipykernel                          4.8.2      
ipython                            5.7.0      
ipython-genutils                   0.2.0      
ipywidgets                         7.2.1      
Jinja2                             2.10       
joblib                             0.9.4      
jsonschema                         2.6.0      
jupyter                            1.0.0      
jupyter-client                     5.2.3      
jupyter-console                    5.2.0      
jupyter-core                       4.4.0      
lxml                               4.2.3      
lz4                                0.7.0      
Markdown                           2.6.9      
MarkupSafe                         1.0        
matplotlib                         2.1.1      
meld                               3.14.2     
mistune                            0.8.3      
mock                               2.0.0      
mpi4py                             1.3.1      
msgpack-python                     0.4.6      
mvnc                               1.11.0.2   
nbconvert                          5.3.1      
nbformat                           4.4.0      
networkx                           2.0        
nose                               1.3.7      
notebook                           5.5.0      
numpy                              1.13.3     
olefile                            0.44       
PAM                                0.4.2      
pandocfilters                      1.4.2      
pathlib2                           2.3.2      
pbr                                3.1.1      
pexpect                            4.6.0      
pickleshare                        0.7.4      
Pillow                             4.3.0      
pip                                18.0       
poster                             0.8.1      
prompt-toolkit                     1.0.15     
protobuf                           3.4.0      
psutil                             5.4.0      
ptyprocess                         0.5.2      
pyasn1                             0.1.9      
pyasn1-modules                     0.0.7      
Pygments                           2.2.0      
pygobject                          3.20.0     
pyOpenSSL                          0.15.1     
pyparsing                          2.2.0      
pyserial                           3.0.1      
Pyste                              0.9.10     
python-dateutil                    2.6.1      
python-snappy                      0.5        
pytz                               2017.3     
PyWavelets                         0.5.2      
pyzmq                              17.0.0     
qtconsole                          4.3.1      
scandir                            1.7        
scikit-image                       0.13.1     
scikit-learn                       0.19.1     
scipy                              1.0.0      
Send2Trash                         1.5.0      
service-identity                   16.0.0     
setuptools                         36.6.0     
Shapely                            1.6.4.post1
simplegeneric                      0.8.1      
simplejson                         3.8.1      
singledispatch                     3.4.0.3    
six                                1.11.0     
subprocess32                       3.2.7      
tensorflow-gpu                     1.3.0      
tensorflow-tensorboard             0.1.8      
terminado                          0.8.1      
testpath                           0.3.1      
tornado                            5.0.2      
traitlets                          4.3.2      
trollius                           2.0.1      
Twisted                            16.0.0     
txaio                              1.0.0      
unity-lens-photos                  1.0        
virtualenv                         15.1.0     
wcwidth                            0.1.7      
Werkzeug                           0.12.2     
wheel                              0.30.0     
widgetsnbextension                 3.2.1      
zope.interface                     4.1.3      
You are using pip version 18.0, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
strong@foreverstrong:~$ 
strong@foreverstrong:~$ pip show hmmlearn
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Name: hmmlearn
Version: 0.2.0
Summary: Hidden Markov Models in Python with scikit-learn like API
Home-page: https://github.com/hmmlearn/hmmlearn
Author: Sergei Lebedev
Author-email: [email protected]
License: new BSD
Location: /home/strong/.local/lib/python2.7/site-packages
Requires: 
Required-by: 
You are using pip version 18.0, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
strong@foreverstrong:~$ 
strong@foreverstrong:~$ pip3 list
The program 'pip3' is currently not installed. You can install it by typing:
sudo apt install python3-pip
strong@foreverstrong:~$ 

猜你喜欢

转载自blog.csdn.net/chengyq116/article/details/83794489