首页 > 系统相关 >Python Linux源码安装

Python Linux源码安装

时间:2024-07-04 16:19:22浏览次数:19  
标签:bin Python iZbp1ac4pv22mg092qi2zfZ 源码 Linux pip root 3.8

保留服务器原Python安装版本,安装指定需求版本Python

1.查看当前系统版本

[root@iZbp1ac4pv22mg092qi2zfZ ~]# cat /etc/system-release
CentOS Linux release 7.9.2009 (Core)

2.查看已安装Python路径及版本

[root@iZbp1ac4pv22mg092qi2zfZ ~]# which python
/usr/bin/python
[root@iZbp1ac4pv22mg092qi2zfZ ~]# which python3
/usr/bin/python3
[root@iZbp1ac4pv22mg092qi2zfZ ~]# python -V
Python 2.7.5
[root@iZbp1ac4pv22mg092qi2zfZ ~]# python3 -V
Python 3.6.8

3.下载需要想Python源码包

[root@iZbp1ac4pv22mg092qi2zfZ workspace_python]# wget https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tgz

4.解压

[root@iZbp1ac4pv22mg092qi2zfZ workspace_python]# tar -xzvf Python-3.8.6.tgz

5.安装

5.1安装编译可能需要的库或者依赖

[root@iZbp1ac4pv22mg092qi2zfZ workspace_python]# cd Python-3.8.6/
[root@iZbp1ac4pv22mg092qi2zfZ workspace_python]# sudo install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel

5.2创建安装路径,编译安装

[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# mkdir -p /opt/python3.8
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# ./configure --prefix=/opt/python3.8
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# make && make install

5.3安装完成提示

Installing collected packages: setuptools, pip
  WARNING: The script easy_install-3.8 is installed in '/opt/python3.8/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pip3 and pip3.8 are installed in '/opt/python3.8/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.2.1 setuptools-49.2.1

6.创建软连接

当前Python3是链接Python3.6的,改成新编译的Python3.8.6

[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# which python3
/usr/bin/python3
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 9 Feb  8  2023 /usr/bin/python3 -> python3.6
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# ls -l /usr/bin/python3.6
-rwxr-xr-x 2 root root 11328 Nov 17  2020 /usr/bin/python3.6
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# rm /usr/bin/python3
rm: remove symbolic link ‘/usr/bin/python3’? yes
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# ln -s /opt/python3.8/bin/python3 /usr/bin/python3

同样设置链接一下pip

[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# rm -rf /usr/bin/pip3
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# ln -s /opt/python3.8/bin/pip3 /usr/bin/pip3

7.测试

[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# python3 -V
Python 3.8.6
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# pip3 -V
pip 20.2.1 from /opt/python3.8/lib/python3.8/site-packages/pip (python 3.8)
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# pip3 list
Package    Version
---------- -------
pip        20.2.1
setuptools 49.2.1
WARNING: The repository located at mirrors.cloud.aliyuncs.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.cloud.aliyuncs.com'.

有个WARNING,解决方法

pip.conf 加上

trusted-host=mirrors.cloud.aliyuncs.com
[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# vim ~/.pip/pip.conf
[global]
index-url=http://mirrors.cloud.aliyuncs.com/pypi/simple/
trusted-host=mirrors.cloud.aliyuncs.com
[install]

再测试一下

[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# pip3 list
Package    Version
---------- -------
pip        20.2.1
setuptools 49.2.1
WARNING: You are using pip version 20.2.1; however, version 24.1.1 is available.
You should consider upgrading via the '/opt/python3.8/bin/python3.8 -m pip install --upgrade pip' command.

更新最新的pip版本

[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# /opt/python3.8/bin/python3.8 -m pip install --upgrade pip

将pip使用清华源

[root@iZbp1ac4pv22mg092qi2zfZ Python-3.8.6]# pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

标签:bin,Python,iZbp1ac4pv22mg092qi2zfZ,源码,Linux,pip,root,3.8
From: https://www.cnblogs.com/xp1763/p/18284102

相关文章

  • 有趣的Python库——CowSay
    有趣的Python库——CowSay安装:pipinstallcowsay命令式使用:cowsay-cpig-t你好,我是一只猪哦!输出:__________|你好,我是一只猪哦!|==========\\\\,.(_|,......
  • 40个Python函数-助你快速成为编程高手
    40个Python函数-助你快速成为编程高手1、「len()」-返回对象的长度或项目数。length=len("Hello,World!")#返回132、「str()」-将对象转换成字符串。string_representation=str(123)#返回'123'3、「type()」-返回对象的类型。type_of_var=type......
  • 第15届蓝桥杯Python青少组选拔赛(STEMA)2023年8月真题-附答案
    第15届蓝桥杯Python青少组选拔赛(STEMA)2023年8月真题题目总数:11总分数:400真题下载点我百度网盘......
  • Linux下使用arping检测IP地址是否冲突
    arping简介在Linux中,arping是一个用来发送ARP请求到一个相邻主机的工具,通常用于检测网络上的IP地址冲突。使用arping检测IP地址是否冲突的方法例1:使用如下命令检测10.206.216.95是否冲突(使用-I参数指定网络接口)#arping-Ieth010.206.216.95ARPING10.206.216.95......
  • xalpha-一个可以预测股票,基金走势的Python库
    xalpha-一个可以预测股票,基金走势的Python库xalpha是什么xalpha是一个开源的Python库,主要用于量化投资和数据分析。它集成了大量的金融数据接口,提供了丰富的API用于股票、期货、外汇等金融数据的获取和处理。xalpha的设计简洁明了,易于上手,让初中级程序员也能轻松地进行金......
  • ChatterBot-基于Python库的聊天机器人框架
    ChatterBot-基于Python库的聊天机器人框架ChatterBot是什么ChatterBot是一个基于Python的聊天机器人框架,它可以帮助我们快速地创建各种聊天机器人。它使用了NLP(自然语言处理)技术,可以理解和回答用户的问题。ChatterBot的设计目标是易于使用,灵活,支持多种输出格式,如文本、语......
  • 地表最强的Python开源库,可让微信秒变助手的-itchat
    地表最强的Python开源库,可让微信秒变助手的-itchatitchat是什么itchat是一个开源的Python库,主要用于微信个人号的接口。通过这个库,开发者可以实现自动回复、模拟人工操作、实现机器人等功能。itchat的出现极大地降低了微信个人号开发的门槛,让更多的开发者能够轻松地实现......
  • 钉钉应用开发-Python操作钉钉文档(excel版)
    钉钉应用开发-Python操作钉钉文档一:服务端SDK下载服务端SDK下载-钉钉开放平台(dingtalk.com)pip3installalibabacloud_dingtalk二:钉钉开放平台开发者后台(dingtalk.com)基础概念-钉钉开放平台(dingtalk.com)2.1:创建应用2.2:获取应用基本信息2.3:权限申请,获取......
  • linux进程被杀掉日志,Linux进程突然被杀掉(OOM killer),查看系统日志
    Linux进程被杀掉(OOMkiller),查看系统日志基本概念:Linux内核有个机制叫OOMkiller(OutOfMemorykiller),该机制会监控那些占用内存过大,尤其是瞬间占用内存很快的进程,然后防止内存耗尽而自动把该进程杀掉。内核检测到系统内存不足、挑选并杀掉某个进程的过程可以参考内核源代码......
  • Python之Web框架Django
    官网https://www.djangoproject.com/download/安装djangopip安装django#查看python版本,版本显示如下Python3.12.1python3-V#安装djangopython3-mpipinstallDjango==5.0.6#查看django版本python3-mdjango--version通过Django包离线安装下载Django项目并......