Alpine安装python踩坑

Alpine 安装 python3

# 1. 替换alpine下载源,类似yum源
sed -i s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g /etc/apk/repositories

# 2. apk安装python3 
apk add --update --no-cache curl jq py3-configobj py3-setuptools python3 python3-dev

# 2.1 alpine基础环境安装:
# pip安装包时是即时编译,如缺少基础环境依赖会报错
apk add --no-cache gcc g++ libffi-dev make zlib-dev libcec-dev libtool 


# 2.1 pip3 安装
apk add wget
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py


# 3. 设置国内pip源
vim  ~/.pip/pip.conf
# 贴入下面配置
[global]
index-url = http://mirrors.aliyun.com/pypi/simple
[install]
trusted-host=mirrors.aliyun.com


# 4. 使用pip/pip3下载依赖包
# python包写入文件
pip3 freeze > requirements.txt
# python包安装文件
pip3 install -r requirements.txt

你可能感兴趣的:(Alpine,Linux,Python3,pip,国内源,安装教程)