分类: Linux

  • 【技术分享】使用 pip 的国内镜像源

    pip 默认访问国外的镜像源来安装 Python 包会很慢且困难,为了提高下载速度,可以指定国内的镜像源。

    在安装包时,可以使用 -i 参数指定临时镜像源。例如,使用清华大学的镜像源安装 django 包:

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

    永久指定 pip 镜像源的操作方法:

    在 Linux 或 macOS 系统中:
    创建或修改 ~/.pip/pip.conf 文件(如果不存在该目录,可以先运行 mkdir ~/.pip)内容如下:

    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    [install]
    trusted-host = pypi.tuna.tsinghua.edu.cn

    在 Windows 系统中:
    创建或修改 %HOMEPATH%\pip\pip.ini 文件,在该文件中添加以下内容:

    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    [install]
    trusted-host = pypi.tuna.tsinghua.edu.cn

    以下是一些常用的国内镜像源地址:

    清华大学:https://pypi.tuna.tsinghua.edu.cn/simple
    阿里云:http://mirrors.aliyun.com/pypi/simple/
    中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple/

  • 【技术分享】manjaro 2024 pacman 未能同步所有数据库错误

    Manjaro (一个Linux桌面发行版基于Arch)执行 sudo pacman -Syu 或者 -Syuu 更新软件或升级Manjaro系统的时候遇到“错误:未能同步所有数据库(软件仓库没有配置服务器信息)

    解决方法,就是更换pacman的源,使用中国的镜像源,命令如下:

    sudo pacman-mirrors -c china