Python入门之pip永久镜像源的配置方法

作者:

文章目录
  • 国内几个好用的Python镜像服务器地址: 1. 清华大学镜像站:https://pypi.tuna.tsinghua.edu.cn/simple/ 2. 阿里云镜像站:https://mirrors.aliyun.com/pypi/simple/ 3. 中科大镜像站:https://pypi.mirrors.ustc.edu.cn/simple/ 4. 中国科技大学镜像站:https://pypi.mirrors.ustc.edu.cn/simple/ 5. 中国科学技术大学镜像站:https://pypi.mirrors.ustc.edu.cn/simple/ 6. 华中科技大学镜像站:https://pypi.hustunique.com/
  • pip install -i +国内镜像地址 +模块名称 或 pip install +模块名称 -i +国内镜像地址 pip install pyperclip -i https://pypi.tuna.tsinghua.edu.cn/simple
  • 这样不用每次安装库的时候+镜像地址,省事不少。 A、首先,需要确定一个可靠能用的镜像源。一些常用的Python镜像源包括阿里云、清华大学和豆瓣等。可以在官方网站上查找具体的镜像源地址。 B、在终端或cmd命令提示符中设置指定的镜像源地址: pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple C、配置好之后,现在可以加速安装第三方模块了。在终端或命令提示符中输入以下命令:(此时就自动带一个镜像源,pip install +库名即可) pip install pyperclip D、查看当前配置的镜像源地址 pip config list
  • 这些基本用于管理本地和全局配置 列出配置:使用pip config list 命令,可以列出当前pip的所有配置项。 编辑配置:使用pip config edit命令,可以在默认编辑器中编辑当前的配置文件。 设置配置:使用pip config set命令,可以设置或修改配置项的值。例如,pip config set global.proxy http://proxy.example.com:8080。 获取配置:使用pip config get命令,可以获取当前配置项的值。例如,pip config get global.proxy。 删除配置:使用pip config unset命令,可以删除配置项。例如,pip config unset global.proxy。 查看调试信息:使用pip config debug命令,可以查看当前的调试信息。
  • python永久配置阿里云镜像源 在 Python 中配置阿里云镜像源(阿里云 PyPI 镜像)可以显著提升国内下载速度。以下是详细配置方法: 1.临时使用阿里云 在安装包时直接指定阿里云镜像: pip install 包名 -i https://mirrors.aliyun.com/pypi/simple –trusted-host mirrors.aliyun.com 2.永久配置阿里云源 方法一:修改 pip 配置文件(推荐) Windows 系统: 1. 打开文件资源管理器,输入路径:   %APPDATA%pip 2. 创建或编辑 `pip.ini` 文件,添加: [global] index-url = https://mirrors.aliyun.com/pypi/simple trusted-host = mirrors.aliyun.com Linux/macOS 系统: 1. 创建或编辑配置文件: mkdir -p ~/.pip && nano ~/.pip/pip.conf   2. 写入以下内容: [global] index-url = https://mirrors.aliyun.com/pypi/simple trusted-host = mirrors.aliyun.com 方法二:命令行一键配置 pip config set global.index-url https://mirrors.aliyun.com/pypi/simple pip config set global.trusted-host mirrors.aliyun.com 验证配置是否生效 pip config list 输出应包含: global.index-url='https://mirrors.aliyun.com/pypi/simple'global.trusted-host='mirrors.aliyun.com' 恢复默认源 pip config unset global.index-url pip config unset global.trusted-host 阿里云镜像源地址 HTTP:http://mirrors.aliyun.com/pypi/simpleHTTPS:https://mirrors.aliyun.com/pypi/simple windows下永久配置pip镜像源 %userprofile%或%homepath%下新建目录pip 在pip目录下,新建文件pip.ini 文件内容如下: [global]index-url = https://mirrors.aliyun.com/pypi/simple  trusted-host = mirrors.aliyun.com  timeout = 6000  到此这篇关于Python入门之pip永久镜像源的配置方法的文章就介绍到这了,更多相关Python pip永久配置镜像源内容请搜索风君子博客以前的文章或继续浏览下面的相关文章希望大家以后多多支持风君子博客! 您可能感兴趣的文章: Python配置pip国内镜像源的实现 Python-pip配置国内镜像源的安装方式 Python-pip配置国内镜像源快速下载包的方法详解 Python Anaconda以及Pip配置清华镜像源代码示例 python pip配置国内镜像源的方法(永久和临时)
  • 目录
    • 国内镜像源
    • 1.临时镜像源的安装命令
    • 2.永久镜像源的配置方法
    • 3.pip config常用命令
    • 4.方法补充

    国内几个好用的Python镜像服务器地址:

    1. 清华大学镜像站:https://pypi.tuna.tsinghua.edu.cn/simple/

    2. 阿里云镜像站:https://mirrors.aliyun.com/pypi/simple/

    3. 中科大镜像站:https://pypi.mirrors.ustc.edu.cn/simple/

    4. 中国科技大学镜像站:https://pypi.mirrors.ustc.edu.cn/simple/

    5. 中国科学技术大学镜像站:https://pypi.mirrors.ustc.edu.cn/simple/

    6. 华中科技大学镜像站:https://pypi.hustunique.com/

    pip install -i +国内镜像地址 +模块名称 或 pip install +模块名称 -i +国内镜像地址

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

    这样不用每次安装库的时候+镜像地址,省事不少。

    A、首先,需要确定一个可靠能用的镜像源。一些常用的Python镜像源包括阿里云、清华大学和豆瓣等。可以在官方网站上查找具体的镜像源地址。

    B、在终端或cmd命令提示符中设置指定的镜像源地址:

    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

    C、配置好之后,现在可以加速安装第三方模块了。在终端或命令提示符中输入以下命令:(此时就自动带一个镜像源,pip install +库名即可)

    pip install pyperclip
    

    D、查看当前配置的镜像源地址

    pip config list
    

    这些基本用于管理本地和全局配置

    列出配置:使用pip config list 命令,可以列出当前pip的所有配置项。

    编辑配置:使用pip config edit命令,可以在默认编辑器中编辑当前的配置文件。

    设置配置:使用pip config set命令,可以设置或修改配置项的值。例如,pip config set global.proxy http://proxy.example.com:8080。

    获取配置:使用pip config get命令,可以获取当前配置项的值。例如,pip config get global.proxy。

    删除配置:使用pip config unset命令,可以删除配置项。例如,pip config unset global.proxy。

    查看调试信息:使用pip config debug命令,可以查看当前的调试信息。

    python永久配置阿里云镜像源

    在 Python 中配置阿里云镜像源(阿里云 PyPI 镜像)可以显著提升国内下载速度。以下是详细配置方法:

    1.临时使用阿里云

    在安装包时直接指定阿里云镜像:

    pip install 包名 -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
    

    2.永久配置阿里云源

    方法一:修改 pip 配置文件(推荐)

    Windows 系统:

    1. 打开文件资源管理器,输入路径:

      %APPDATA%pip

    2. 创建或编辑 `pip.ini` 文件,添加:

         [global]
         index-url = https://mirrors.aliyun.com/pypi/simple
         trusted-host = mirrors.aliyun.com
    

    Linux/macOS 系统:

    1. 创建或编辑配置文件:

    mkdir -p ~/.pip && nano ~/.pip/pip.conf

      2. 写入以下内容:

         [global]
         index-url = https://mirrors.aliyun.com/pypi/simple
         trusted-host = mirrors.aliyun.com
    

    方法二:命令行一键配置

    pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
    pip config set global.trusted-host mirrors.aliyun.com
    

    验证配置是否生效

    pip config list

    输出应包含:

    global.index-url='https://mirrors.aliyun.com/pypi/simple'
    global.trusted-host='mirrors.aliyun.com'

    恢复默认源

    pip config unset global.index-url
    pip config unset global.trusted-host
    

    阿里云镜像源地址

    HTTP:http://mirrors.aliyun.com/pypi/simple
    HTTPS:https://mirrors.aliyun.com/pypi/simple

    windows下永久配置pip镜像源

    %userprofile%或%homepath%下新建目录pip

    在pip目录下,新建文件pip.ini

    文件内容如下:

    [global]
    index-url = https://mirrors.aliyun.com/pypi/simple  
    trusted-host = mirrors.aliyun.com  
    timeout = 6000 

    到此这篇关于Python入门之pip永久镜像源的配置方法的文章就介绍到这了,更多相关Python pip永久配置镜像源内容请搜索风君子博客以前的文章或继续浏览下面的相关文章希望大家以后多多支持风君子博客!

    您可能感兴趣的文章:

    • Python配置pip国内镜像源的实现
    • Python-pip配置国内镜像源的安装方式
    • Python-pip配置国内镜像源快速下载包的方法详解
    • Python Anaconda以及Pip配置清华镜像源代码示例
    • python pip配置国内镜像源的方法(永久和临时)

    站内搜索