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

An example Analysis of the coexistence of python2 and python3 in centos7 system

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail the example analysis of the coexistence of python2 and python3 under the centos7 system. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Step 1: check the version number and installation path of python

As you can see from the above view, python points to python2 by default, so let's just leave it alone and keep it in its current state.

Note: (because there are still a lot of system updates that need to use pyhton2 for example: Centos7 yum installation and update. Django these frameworks now use python3 by default)

The second step is to install the dependent libraries of python3

1. Installation of python3.7 may rely on yum-y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel wgetyum-y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gccyum-y install libffi-devel 2. Download python3cd / tmp/wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz3. Decompress the downloaded tar-zxvf Python-3.7.4.tgz4. Configure and compile mkdir / usr/local/python3cd Python-3.7.4/. / configure-enable-shared-prefix=/usr/local/python3-enable-optimizationsmakemake install

Step 4, after the installation is complete, create the soft link.

Later use is to directly enter python to run or python2. Type python3 to run pyhton3.

Cd / usr/local/python3/bin/ln-s / usr/local/python3/bin/python3 / usr/bin/python3ln-s / usr/local/python3/bin/pip3 / usr/bin/pip3pip3 install-- upgrade pip

The following error may occur in this step:

Error prompt:

Python3: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

Solution: (just go to the installation directory and copy the files)

Cd / tmp/Python-3.7.4/cp libpython3.7m.so.1.0 / usr/local/lib64cp libpython3.7m.so.1.0 / usr/lib/cp libpython3.7m.so.1.0 / usr/lib64/

Step 5, complete all the installation, and establish the Python virtual environment in the next update

This is the end of this article on "example Analysis of the coexistence of python2 and python3 in centos7 system". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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