当前位置:   article > 正文

【Python】Linux、Windows更换镜像源(pip、conda、pycharm)_linux 修改python镜像源

linux 修改python镜像源

“pip” 更换镜像源

临时使用

可以在使用pip的时候加参数-i 镜像地址

国内源

新版ubuntu要求使用https源。

举例:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas

python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

这样就会从清华这边的镜像去安装pandas库。

永久修改

Linux

修改 ~/.pip/pip.conf (Linux系统,没有就创建一个文件夹及文件)

[global] 
timeout = 60000
index-url = http://mirrors.aliyun.com/pypi/simple/ 
[install] 
trusted-host=mirrors.aliyun.com 
  • 1
  • 2
  • 3
  • 4
  • 5

windows

1、WIN+R,然后输入%APPDATA%,会定位到一个新的目录下,我的是

C:\Users\Administrator\AppData\Roaming

2、在该目录下新建pip文件夹

3、然后到pip文件夹里面去新建个pip.ini文件

4、然后打开该文件,将以下内容写入进去

[global]
timeout = 6000
index-url = http://pypi.douban.com/simple
[install] 
trusted-host = pypi.douban.com
  • 1
  • 2
  • 3
  • 4
  • 5

conda” 更换镜像源

终端输入

conda
conda config --show-sources
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
  • 1
  • 2
  • 3
  • 4

“pycharm” 更换镜像源

File >Settings > Project: [项目名] > Project Interpreter > [右边加号] 
> Manager Repositories > [右边加号] > 输入  http://mirrors.aliyun.com/pypi/simple/ 
  • 1
  • 2

批量部署

python中通过requirements.txt来记录项目所有的依赖包及其版本号,以便在其他的环境中部署

python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

pip freeze > requirements.txt

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

镜像地址

机构镜像地址
阿里云http://mirrors.aliyun.com/pypi/simple/
豆瓣http://pypi.douban.com/simple/
清华https://pypi.tuna.tsinghua.edu.cn/simple
中国科技大学https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学http://pypi.hustunique.com/
山东理工大学http://pypi.sdutlinux.org/

Python 安装路径

import sys 
sys.executable
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/343862
推荐阅读
相关标签
  

闽ICP备14008679号