pip 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

pip 命令安装:


-bash: pip command not found

#Debian
apt-get install python-pip

#Ubuntu
apt-get install python-pip

#Arch Linux
pacman -S python-pip

#Kali Linux
apt-get install python-pip

#Fedora
dnf install python-pip

#Raspbian
apt-get install python-pip

pip 命令补充说明:


pip 是 Python 包管理工具,该工具提供了对 Python 包的查找、下载、安装、卸载的功能。

pip 命令语法:


pip <command> [options]
pip3 <command> [options]

pip 命令选项:


#COMMANDS
help          Show help for commands.
install       Install packages.
uninstall     Uninstall packages.
freeze        Output installed packages in requirements format.
list          List installed packages.
show          Show information about installed packages.
search        Search PyPI for packages.
wheel         Build wheels from your requirements.

#GENERAL OPTIONS
-h, --help
Show more detailed command help.

-v, --verbose
Give more output. Option is additive, and can be used up to 3 times.

-V, --version
Show version and exit.

-q, --quiet
Give less output.

--log-file <path>
Path to a verbose non-appending log, that only logs failures. This log is active by default at ~/.pip/pip.log.

--log <path>
Path to a verbose appending log. This log is inactive by default.

--proxy <proxy>
Specify a proxy in the form [user:passwd@]proxy.server:port.

--timeout <sec>
Set the socket timeout (default 15 seconds).

--exists-action <action>
Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.

--cert <path>
Path to alternate CA bundle.

pip 命令实例:


pip 安装软件包:

pip install package_name

安装特定版本的软件包:

pip install package_name==package_version

pip 升级软件包:

pip install -U package_name

pip 卸载软件包:

pip uninstall package_name

pip 将已安装的软件包保存到文件:

pip freeze > requirements.txt

pip 从文件安装软件包:

pip install -r requirements.txt

pip 命令的坑:


如果 Python2 和 Python3 同时有 pip,则使用方法如下:

#Python2:
python2 -m pip install XXX

#Python3:
python3 -m pip install XXX

pip 命令扩展阅读:




pip 命令评论