pip 是“A tool for installing and managing Python packages.”,也就是说pip是python的软件安装工具
2、下面介绍怎么在linux下安装pip
下载pip到/usr/local/src
# cd /usr/local/src
# wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
如果提示:-bash: wget: command not found
那么安装wget,执行如下:
# yum -y install wget
解夺安装pip
# tar -xzvf pip-1.5.4.tar.gz
# cd pip-1.5.4
# python setup.py install
如果安装报下面的错:
Traceback (most recent call last):
File "setup.py", line 6, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
那么就要先安装setuptools包
(1)下载setuptools包
# wget http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
(2)解压setuptools包
# tar zxvf setuptools-2.0.tar.gz
# cd setuptools-2.0
(3)编译setuptools
# python setup.py build
(4)开始执行setuptools安装
# python setup.py install
安装完成setuptools包后,在重新执行:
# cd /usr/local/src/pip-1.5.4
# python setup.py install
至此pip安装完成
3、linux下pip使用参数
# pip --help
Usage:
pip <command>[options]
Commands:
install Install packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
listList installed packages.
showShow information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
zip DEPRECATED. Zip individual packages.
unzip DEPRECATED. Unzip individual packages.
bundle DEPRECATED. Create pybundles.
helpShow help for commands.
General Options:
-h, --help Show 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 /root/.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.
1、linux下安装python3a、 准备编译环境(环境如果不对的话,可能遇到各种问题,比如wget无法下载https链接的文件)1
2
yum groupinstall 'Development Tools'
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel2 下载 Python3.5代码包
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz在安装包中有一个README的文件,里面有写如何安装tar Jxvf Python-3.5.0.tar.xz
cd Python-3.5.0
./configure --prefix=/usr/local/python3
make &&make install
做软链:
ln -s /usr/local/python3/bin/python3.5 /usr/local/bin/python3安装成功了!
如果提示:Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS这是原因没有安装或升级oenssl:
yum install openssl-devel
再次重复编译方案python3.5:
最终如下:
提示同时成功安装pip-7.12与setuptools!
pip3与pip都提示没有错误!
做软链:
ln -s /usr/local/python3/bin/pip3.5 /usr/local/bin/pip升级pip到最新版本:
pip install --upgrade pip
pip安装成功啦!
注:--no-check-certificate 表示安装时“不检查证书”,不加上可能无法安装。
2.安装包
requests包:
pip install requests
pyquery包:
pip install pyquery
pymysql包:
pip install pymysql
这次是想要安装requests模块,如果在windows系统中,直接找到cmd输入pip install requests就好了。但是,在deepin中这样却是不行的因为原本没有pip这个东西,所以要先安装pip。
首先用正常的安装命令:sudo apt-get install python-pip(如果想要安装pip3的话就是python3-pip),之后等待pip安装完成。这个时候再使用pip install requests就行了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)