(1)临时使用:
可以在使用pip的时候,加上参数-i和镜像地址(如https://pypi.tuna.tsinghua.edu.cn/simple),
例如:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspark
这样就会从清华镜像安装pyspark库。
(2)永久修改:
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
cd ~
mkdir -p .pip
nano pip.conf #或者vi pip.conf
在pip.conf中,添加配置内容,内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn