分类 python 下的文章

Go 项目拉取依赖速度慢

export GOPROXY=https://goproxy.cn,direct
export GOPRIVATE=git.mycompany.com,github.com/my/private

Python 项目拉取依赖速度慢

~/.pip/pip.conf文件:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

Node.js 项目拉取依赖速度慢

npm i --registry=https://registry.npmmirror.com --disturl=https://npmmirror.com/dist

Maven 项目拉取依赖速度慢

settings.xml文件:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>aliyunmaven</id>
      <mirrorOf>*</mirrorOf>
      <name>阿里云公共仓库</name>
      <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
  </mirrors>
</settings>

sudo dnf update
sudo dnf install python3.11
sudo dnf install python3.11-pip

编译安装
sudo dnf update
sudo dnf groupinstall "Development Tools" -y
sudo dnf install openssl-devel bzip2-devel libffi-devel -y
cd Python-3.11.0
./configure --enable-optimizations
make -j $(nproc)
sudo make altinstall

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.10
python3.10 --version

安装pip
apt install python3-pip

将Python 3.10设置为默认的Python 3版本
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
sudo update-alternatives --config python3

编译安装
sudo apt install wget build-essential checkinstall
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev curl libbz2-dev
cd Python-3.10.0
sudo ./configure --enable-optimizations
sudo make -j $(nproc)
sudo make altinstall

创建软链接
sudo ln -s /usr/local/bin/python3.10 /usr/bin/python3

配置 pip3
sudo ln -s /usr/local/bin/pip3.10 /usr/bin/pip3

升级pip到最新的版本

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

镜像地址

清华镜像源
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

豆瓣镜像源
pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com some-package

阿里云镜像源
pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com some-package

中国科学技术大学镜像源
pip install -i http://pypi.mirrors.ustc.edu.cn/simple/ --trusted-host=pypi.mirrors.ustc.edu.cn some-package

导出wheel包

导出全部
pip wheel --wheel-dir=./wheelhouse -r requirements.txt -i http://mirrors.ustc.edu.cn/pypi/simple/ --trusted-host mirrors.ustc.edu.cn

导出指定的
pip wheel --wheel-dir=./wheelhouse fastapi==2.2.3 -i http://mirrors.ustc.edu.cn/pypi/simple/ --trusted-host mirrors.ustc.edu.cn --extra-index-url https://test.com/pypi/simple/

安装wheel包

安装全部
pip install wheelhouse/*.whl

安装指定的
pip install --no-index --find-links=wheelhouse fastapi==2.2.3

Debian安装python-ldap的依赖库

apt-get install gcc libldap2-dev libsasl2-dev