python pip国内源_【Python】设置pip源为国内源及简单操作

一、pip国内源镜像:

二、修改源方法:

1.临时修改

可以在使用pip的时候在后面加上-index参数,指定pip源:

pip install --index https://pypi.tuna.tsinghua.edu.cn/simple requests

2.配置文件

Linux

①修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

[root@localhost .pip]# cat ~/.pip/pip.conf

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

②使用:

[root@localhost .pip]# pip install xlwt

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

Collecting xlwt

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/44/48/def306413b25c3d01753603b1a222a011b8621aed27cd7f89cbc27e6b0f4/xlwt-1.3.0-py2.py3-none-any.whl (99 kB)

|████████████████████████████████| 99 kB 735 kB/s

Installing collected packages: xlwt

Successfully installed xlwt-1.3.0

Windows:

①在我的电脑上的地址栏输入:%appdata% ,然后回车;

②在里面新建一个名为 pip 的文件夹;

③在 pip 文件夹里面新建一个文件叫做 pip.ini ,内容写如下即可。实际就是这么一个文件 : %appdata%\pip\pip.ini。

文件内容如下:

[global]

timeout = 6000

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

trusted-host = pypi.tuna.tsinghua.edu.cn

④使用pyreadline库,可实现Windows中python的tab键补全,安装如下:

C:\Users\annie.wu>pip install pyreadline

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

Collecting pyreadline

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/7c/d724ef1ec3ab2125f38a1d53285745445ec4a8f19b9bb0761b4064316679/pyreadline-2.1.zip (109kB)

|████████████████████████████████| 112kB 1.1MB/s

Installing collected packages: pyreadline

Running setup.py install for pyreadline ... done

Successfully installed pyreadline-2.1

WARNING: You are using pip version 19.2.3, however version 20.1 is available.

You should consider upgrading via the 'python -m pip install --upgrade pip' command.

3.简单操作

①接下来,用 pip 试试安装各种库:

pip install xlwt

pip install xlrd

pip install six

pip install requests

pip install oauthlib

pip install requests_oauthlib

②其他使用示例

升级pip

python -m pip install -U pip

安装相关库

python -m pip install psutil

卸载相关库

python -m pip uninstall psutil

查看已安装的库

python -m pip freeze

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值