#查看pip版本,cmd命令窗口(注意环境变量%PYTHON_HOME%\scripts,是否在path中)
pip --version
#安装pip,cmd命令窗口
python -m pip install pip
#查看已安装模块,cmd命令窗口
python -m pydoc modules
#查看已安装第三方库,cmd命令窗口
pip list
#安装模块xlrd2,cmd命令窗口
pip install xlrd2
python -m pip install --upgrade pywin32
#查看模块版本,python窗口
import xlrd2
print(xlrd2.version)
#pip下载速度过慢的原因就是 pip 默认使用的是国外的源,将国外的源换成国内
方式一:下载时加入参数 -i [镜像源地址]
pip install numpy -i http://mirrors.aliyun.com/pypi/simple/
方式二:设置源
(1)语法如下:
pip config set global.index-url mirror_url_path #指定镜像服务器域名地址
pip config set global.timeout number #设置连接超时时间,以秒为单位,指定number秒后,连接超时
pip config set install.trusted-host hostname #将以上镜像服务器的域名加入到Install命令的信任域名列表内
(2)示例如下:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set install.trusted-host mirrors.aliyun.com
(3)查看
pip config list
注:pip国内镜像源
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣 http://pypi.douban.com/simple
中国科学院 http://pypi.mirrors.opencas.cn/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/