由网络副手--寻路人于2024.09.11 23:12:00发布在服务器运维,Python Centos7.9 安装python3.12.4 阅读215 评论1 喜欢0 安装前准备工作: 1、[重新安装Openssl 1.1.1w](http://www.bravedu.com/archives/270/ "重新安装Openssl 1.1.1w") 2、[替换镜像配置](http://www.bravedu.com/archives/271/ "替换镜像配置") 3、[升级gcc 4.8.5 -> gcc 11](http://www.bravedu.com/archives/272/ "升级gcc 4.8.5 -> gcc 11") 安装: python3.12.4 一、下载解压 ``` wget https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tar.xz tar xzvf Python-3.12.4.tar.xz ``` 二、安装依赖: ``` sudo yum -y groupinstall "Development Tools" sudo yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel gcc-c++ ``` 三、编译安装 ``` cd Python-3.12.4 ./configure --enable-optimizations --prefix=/usr/local/python3.12 --with-openssl=/usr/local/openssl-1.1.1w sudo make && sudo make install sudo ln -s /usr/local/python3.12/bin/python3.12 /usr/bin/python3.12 ``` 四、创建虚拟机 ``` python -m venv aa_env source aa_env/bin/activate ``` 五、升级pip ``` pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com --upgrade pip ``` 六、安装服务 ``` pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ ``` 解决--trusted-host mirrors.aliyun.com 一、修改镜像 ``` pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ ``` ``` 常用镜像源 豆瓣 http://pypi.douban.com/ 华中理工大学 http://pypi.hustunique.com/ 山东理工大学 http://pypi.sdutlinux.org/ 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/ 阿里云 https://mirrors.aliyun.com/pypi/simple/ ``` 二、在虚拟环境文件夹加入,pip.conf该方法是一劳永逸 避免--trusted-host mirrors.aliyun.com ``` vim aa_env/pip.conf [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com ``` 赞 0 分享 赏 您可以选择一种方式赞助本站 支付宝扫码赞助 BraveDu 署名: 网络副手~寻路人
作者对主题的挖掘深入骨髓,展现了非凡的洞察力和理解力。