In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to achieve the coexistence of python2 and python3 under the centos7 system". In the daily operation, I believe that many people have doubts about how to achieve the coexistence of python2 and python3 under the centos7 system. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to achieve the coexistence of python2 and python3 under the centos7 system". Next, please follow the editor to study!
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
At this point, the study on "how to achieve the coexistence of python2 and python3 under the centos7 system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.