编译安装python 3.11
先处理下opensll的版本,以免编python译环境异常:安装 openssl-1.1.1
yum remove openssl
cd /opt
wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz
tar -zxvf openssl-1.1.1n.tar.gz
cd openssl-1.1.1n/
./config --prefix=/opt/openssl
make depend
make && make install
ln -sf /opt/openssl/bin/openssl /usr/bin/openssl #需要默认在/usr/bin/下创建openssl的软连接
echo "/opt/openssl/lib/" >> /etc/ld.so.conf #需要在环境变量中增加这一行代码
ldconfig -v #使配置生效
openssl version
配置环境变量,在末尾加入代码 echo "/opt/openssl/lib/" >> /etc/ld.so.conf
1、去python3的官方网站下载源代码
https://www.python.org/downloads/
cd /opt
wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tar.xz
我的网络不好,手动下载后再上传到/opt目录下
2、解压缩
tar -xvJf Python-3.11.2.tar.xz
安装编译环境
yum -y groupinstall "Development tools"
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
yum install libffi-devel -y
3、指定安装路径
mkdir /opt/python3 #创建编译安装目录
cd /opt/Python-3.11.2
#####./configure --prefix=/opt/python3####这条报错,需要下面这个
./configure --prefix=/opt/python3 --with-openssl=/opt/openssl --with-openssl-rpath=auto
已经自动生成了creating Makefile
4、编译并安装
root@jumpserver-app-t01:/opt/Python-3.11.2#make
root@jumpserver-app-t01:/opt/Python-3.11.2#make install
分割线
环境变量的意义,在于项目之间不相互干扰,Linux系统自带python2的环境,使用虚拟环境不会影响系统调用
运行python3的两种方式
方式1:使用绝对路径
root@jumpserver-app-t01:/opt#/opt/python3/bin/python3
Python 3.6.10 (default, Feb 20 2023, 22:17:54)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
root@jumpserver-app-t01:/opt#
方式2:使用环境变量的方式(相互不干扰)
echo PATH="/opt/python3/bin:$PATH" >> /etc/profile
source /etc/profile
此时显示PATH的环境变量中就有了python3,使用python命令补全也有python2和python3
root@jumpserver-app-t01:/bin#echo PATH="/opt/python3/bin:$PATH" >> /etc/profile
root@jumpserver-app-t01:/bin#source /etc/profile
root@jumpserver-app-t01:/bin#echo $PATH
/opt/python3/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/root/bin
root@jumpserver-app-t01:/bin#python
python python2.7 python2-config python3.11 python3-config
python2 python2.7-config python3 python3.11-config python-config
root@jumpserver-app-t01:/bin#pip
pip pip2 pip2.7 pip3 pip3.11
root@jumpserver-app-t01:/bin#
明确python、python3、pip、pip3的安装路径
root@jumpserver-app-t01:/opt#which python
/usr/bin/python
root@jumpserver-app-t01:/opt#which python3
/opt/python3/bin/python3
root@jumpserver-app-t01:/opt#which pip
/usr/bin/pip
root@jumpserver-app-t01:/opt#which pip3
/opt/python3/bin/pip3
root@jumpserver-app-t01:/opt#
5、Python3创建虚拟环境
安装虚拟环境工具,python3是解释器,需要pip3工具给python3安装模块。这类似于Linux系统中的yum工具。
Python3的程序在运行的时候,必须要用pip3安装一些模块才能正常的运行。
先更新一下pip3的下载源,方便快速下载
root@jumpserver-app-t01:/opt#mkdir ~/.pip
root@jumpserver-app-t01:/opt#touch ~/.pip/pip.conf
root@jumpserver-app-t01:/opt#vim ~/.pip/pip.conf
root@jumpserver-app-t01:/opt#cat ~/.pip/pip.conf
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
root@jumpserver-app-t01:/opt#pip3 install virtualenv
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting virtualenv
Downloading https://mirrors.aliyun.com/pypi/packages/18/a2/7931d40ecb02b5236a34ac53770f2f6931e3082b7a7dafe915d892d749d6/virtualenv-20.17.1-py3-none-any.whl (8.8MB)
100% |████████████████████████████████| 8.9MB 404kB/s
Collecting distlib<1,>=0.3.6 (from virtualenv)
Downloading https://mirrors.aliyun.com/pypi/packages/76/cb/6bbd2b10170ed991cf64e8c8b85e01f2fb38f95d1bc77617569e0b0b26ac/distlib-0.3.6-py2.py3-none-any.whl (468kB)
100% |████████████████████████████████| 471kB 401kB/s
Collecting importlib-resources>=5.4; python_version < "3.7" (from virtualenv)
Downloading https://mirrors.aliyun.com/pypi/packages/24/1b/33e489669a94da3ef4562938cd306e8fa915e13939d7b8277cb5569cb405/importlib_resources-5.4.0-py3-none-any.whl
Collecting importlib-metadata>=4.8.3; python_version < "3.8" (from virtualenv)
Downloading https://mirrors.aliyun.com/pypi/packages/a0/a1/b153a0a4caf7a7e3f15c2cd56c7702e2cf3d89b1b359d1f1c5e59d68f4ce/importlib_metadata-4.8.3-py3-none-any.whl
Collecting platformdirs<3,>=2.4 (from virtualenv)
Downloading https://mirrors.aliyun.com/pypi/packages/b1/78/dcfd84d3aabd46a9c77260fb47ea5d244806e4daef83aa6fe5d83adb182c/platformdirs-2.4.0-py3-none-any.whl
Collecting filelock<4,>=3.4.1 (from virtualenv)
Downloading https://mirrors.aliyun.com/pypi/packages/84/ce/8916d10ef537f3f3b046843255f9799504aa41862bfa87844b9bdc5361cd/filelock-3.4.1-py3-none-any.whl
Collecting zipp>=3.1.0; python_version < "3.10" (from importlib-resources>=5.4; python_version < "3.7"->virtualenv)
Downloading https://mirrors.aliyun.com/pypi/packages/bd/df/d4a4974a3e3957fd1c1fa3082366d7fff6e428ddb55f074bf64876f8e8ad/zipp-3.6.0-py3-none-any.whl
Collecting typing-extensions>=3.6.4; python_version < "3.8" (from importlib-metadata>=4.8.3; python_version < "3.8"->virtualenv)
Downloading https://mirrors.aliyun.com/pypi/packages/45/6b/44f7f8f1e110027cf88956b59f2fad776cca7e1704396d043f89effd3a0e/typing_extensions-4.1.1-py3-none-any.whl
Installing collected packages: distlib, zipp, importlib-resources, typing-extensions, importlib-metadata, platformdirs, filelock, virtualenv
Successfully installed distlib-0.3.6 filelock-3.4.1 importlib-metadata-4.8.3 importlib-resources-5.4.0 platformdirs-2.4.0 typing-extensions-4.1.1 virtualenv-20.17.1 zipp-3.6.0
You are using pip version 18.1, however version 21.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@jumpserver-app-t01:/opt#
6、使用虚拟环境工具,再创建一个Python3解释器,命名为venv1_jump环境名称
pip3 install virtualenv
pip3 install --upgrade pip3
cd /opt
virtualenv --python=python3 venv1_jump
root@jumpserver-app-t01:/opt#virtualenv --python=python3 venv1_jump
created virtual environment CPython3.11.2.final.0-64 in 193ms
creator CPython3Posix(dest=/opt/venv1_jump, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
added seed packages: pip==23.0, setuptools==67.1.0, wheel==0.38.4
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
root@jumpserver-app-t01:/opt#
此时,你的Linux服务器上就有2个python3解释器了
a、查看默认的python3解释器——解释器本体在/opt/python3/bin/python3
root@jumpserver-app-t01:/opt#which python3
/opt/python3/bin/python3
root@jumpserver-app-t01:/opt#
b、我们创建的另一个虚拟解释器,路径是/opt/venv1_jump/bin/python3
root@jumpserver-app-t01:/opt#/opt/venv1_jump/bin/python3
Python 3.11.2 (main, Feb 21 2023, 21:53:52) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
root@jumpserver-app-t01:/opt#
7、激活虚拟环境,source /opt/venv1_jump/bin/activate进入虚拟环境后,环境变量发生了改变
root@jumpserver-app-t01:/opt#source /opt/venv1_jump/bin/activate
(venv1_jump) root@jumpserver-app-t01:/opt#echo $PATH
/opt/venv1_jump/bin:/opt/python3/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/root/bin
(venv1_jump) root@jumpserver-app-t01:/opt#which python3
/opt/venv1_jump/bin/python3
(venv1_jump) root@jumpserver-app-t01:/opt#
我们看到,虚拟环境(venv1_jump)的环境变量是这样的,/opt/jum_venv1/bin:/opt/python3-6-10/bin:/opt/python3-6-10/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/root/bin:/root/bin
因为环境变量的查找顺序是从左往右的顺序读取的,因此会优先找到/opt/jum_venv1/bin:
8、最后退出环境变量的方法是deactivate
(venv1_jump) root@jumpserver-app-t01:/opt#deactivate
root@jumpserver-app-t01:/opt#
#安装Redis 3.2.12 #此版本太低,高版本jumpserver不可以使用
mysql关系型数据库,磁盘型数据库,数据是以文件形式,存储在磁盘上的,可以持久化长期存储
redis内存性数据库,缓存型数据库。将一些频繁读取的数据放在内存中调用使用,加快web集群性能。
root@jumpserver-app-t01.novalocal:/opt#yum install redis -y
Complete!
root@jumpserver-app-t01.novalocal:/opt#systemctl start redis
root@jumpserver-app-t01.novalocal:/opt#systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
root@jumpserver-app-t01.novalocal:/opt#
检查redis的端口运行情况6379端口
root@jumpserver-app-t01.novalocal:/opt#netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2408/sshd: /usr/sbi
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 8607/redis-server 1
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 875/rpcbind
tcp 0 0 0.0.0.0:10032 0.0.0.0:* LISTEN 1578/java
tcp6 0 0 :::22 :::* LISTEN 2408/sshd: /usr/sbi
tcp6 0 0 :::3306 :::* LISTEN 89110/mysqld
tcp6 0 0 :::111 :::* LISTEN 875/rpcbind
udp 0 0 0.0.0.0:68 0.0.0.0:* 23060/dhclient
udp 0 0 0.0.0.0:111 0.0.0.0:* 875/rpcbind
udp 0 0 10.22.2.160:123 0.0.0.0:* 879/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 879/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 879/ntpd
udp 0 0 0.0.0.0:613 0.0.0.0:* 875/rpcbind
udp6 0 0 :::111 :::* 875/rpcbind
udp6 0 0 :::123 :::* 879/ntpd
udp6 0 0 :::613 :::* 875/rpcbind
root@jumpserver-app-t01.novalocal:/opt#
登录redis查看是否正常运行:运行ping返回pong
root@jumpserver-app-t01:/opt#redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit
root@jumpserver-app-t01:/opt#
编译安装python 3.11的更多相关文章
- centos7.6编译安装php7.2.11及redis/memcached/rabbitmq/openssl/curl等常见扩展
centos7.6编译安装php7..11及redis/memcached/rabbitmq/openssl/curl等常见扩展 获取Php的编译参数方法: [root@eus-api-cms-bac ...
- 编译安装python
编译安装python 1.下载python3的原码包 1.1下载到到opt目录中 cd /opt 1.2下载python3的原码包 wget https://www.python.org/ftp/py ...
- CentOS 6.7 final编译安装Python 2.7.11
CentOS 6.7默认的Python版本为2.6.6,现升级为Python 2.7.11 1.安装编译环境 yum groupinstall "Development tools" ...
- CentOS6.4 编译安装Python 3.3.2 - CRPER木木
基础环境: CentOS6.4(预装GCC,或者联网YUM---GCC编译写进这里太臃肿,找机会另外写一篇) Python 3.3.2 下载链接: http://www.python.org/ ...
- Centos6.5 源码编译安装 Mysql5.7.11及配置
安装环境 Linux(CentOS6.5 版).boost_1_59_0.tar.gz.mysql-5.7.11.tar.gzMySQL 5.7主要特性: 更好的性能:对于多核CPU.固态硬盘. ...
- 在centos上面编译安装python
前言 因为在学习storm的过程中需要安装python,storm是部署在linux上面的,所以需要将python安装在linux上面. 安装准备 python下载 官网链接:https://www. ...
- Linux基础-编译安装Python
终于涉及一点儿专业的了,说实话,对于目前的我难度还是挺大的,这句话送给未来的自己 挑战开始: 首先了解一下Python3.6,底层是由c++开发的,所以在linux下需要C++的支持,必然少不了gcc ...
- CentOS下编译安装python包管理安装工具pip教程
ubuntu 安装pip 代码如下: apt-get install python-pip 安装requests, pip install requests 对于centos的,直接 yum inst ...
- centos7编译安装Python 3.6.8 后用pip3出现SSL未配置问题(import ssl失败)解决方法
下载源码编译安装openssl https://www.openssl.org/source/openssl-1.0.2j.tar.gz ./config --prefix=/usr/local/op ...
- Debian/Ubuntu手动编译安装MongoDB C++11驱动及驱动测试
本文章仅限cnblogs网站内转载!请某网站自觉,遵纪守法,尊重原创! 系统环境情况: 最小化.无桌面环境 新安装的Debian 8 Server 版本操作系统虚拟机一台 手动编译安装MongoDB ...
随机推荐
- iOS16新特性:实时活动-在锁屏界面实时更新APP消息
简介 之前在 <iOS16新特性:灵动岛适配开发与到家业务场景结合的探索实践> 里介绍了iOS16新的特性:实时更新(Live Activity)中灵动岛的适配流程,但其实除了灵动岛的展示 ...
- Eclipse OSGI配置文件说明
- 前端三件套系例之CSS——CSS3基础样式
文章目录 1.宽和高 案例 2.字体属性 2-1 文字字体 2-2 字体大小 2-3 字重(粗细) 2-4 文本颜色 2-5 总结 2-6 案例 文字属性 3-1 文字对齐 3-2 文字装饰 3-3 ...
- ChatGPT 是如何产生心智的?
一.前言 - ChatGPT真的产生心智了吗? 来自斯坦福大学的最新研究结论,一经发出就造成了学术圈的轰动,"原本认为是人类独有的心智理论(Theory of Mind,ToM),已经出现在 ...
- 探索Redis与MySQL的双写问题
本文已收录至GitHub,推荐阅读 Java随想录 微信公众号:Java随想录 原创不易,注重版权.转载请注明原作者和原文链接 目录 双写一致问题 缓存读写策略 Cache-Aside Pattern ...
- VSCode使用JavaScript刷LeetCode配置教程(亲试可以!)
账号秘密都对,但是缺登录不成功的问题 诀窍可能是: 在属性设置中把LeetCode版本改成cn.点击LeetCode配置,修改Endpoint配置项,改成leetcode-cn,再次尝试登陆即可. 大 ...
- kubernetes发布周期
前言 页面介绍了版本发布的一些时间点和PR的要求,通过了解k8s的发布周期来规划自己的版本选择. 合并PR的要求 如果你希望将你的代码合并到官方代码仓库中,不同的开发阶段需要有不同的标签和里程碑.也是 ...
- Go开发IDE全览:GoLand vs VSCode全面解析
关注[TechLeadCloud],分享互联网架构.云服务技术的全维度知识.作者拥有10+年互联网服务架构.AI产品研发经验.团队管理经验,同济本复旦硕,复旦机器人智能实验室成员,阿里云认证的资深架构 ...
- JAVA多线程(2)——锁(对象锁和类锁)
1.如下代码 1 public class TestSync1 implements Runnable { 2 Timer1 timer = new Timer1(); 3 public static ...
- 向量数据库Chroma极简教程
引子 向量数据库其实最早在传统的人工智能和机器学习场景中就有所应用.在大模型兴起后,由于目前大模型的token数限制,很多开发者倾向于将数据量庞大的知识.新闻.文献.语料等先通过嵌入(embeddin ...