Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of Building python3 and realizing coexistence with python2 in CentOS7 Environment

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This paper gives an example of how to build python3 in CentOS7 environment and how to coexist with python2. Share with you for your reference, the details are as follows:

Note:

1. Non-root account plus sudo

2. Centos7 with Python 2.7.5 cannot be uninstalled, and many system-level software rely on this.

Installation dependency

# 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

Download python3. Mine is Python-3.4.2.tgz.

# wget https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tgz# mkdir / usr/local/python3# tar-zxvf Python-3.4.2.tgz# cd Python-3.4.2#. / configure-- prefix=/usr/local/python3# make & & make install# ln-s / usr/local/python3/bin/python3 / usr/bin/python3

test

View version

# python3Python 3.4.2 (default, Jul 19 2016, 03:47:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linuxType "help", "copyright", "credits" or "license" for more information. >

Code testing

Create a new python script hello.py in the current directory

Content:

#! / usr/bin/python3# 's first comment print ("Hello, Python3!") Execute # python3 hello.pyHello, Python3!

I hope what is described in this article will be helpful to the maintenance of CentOS server.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report