In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
It is believed that many inexperienced people don't know what Python upgrade and compatibility configuration is like. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
There is a strange phenomenon in Python. Generally speaking, learning 2 and 3 will be entangled in learning Python. This difference and entanglement between Java5 and Java6 are completely different, because compatibility in Python is indeed a problem. In "fluent Python", it is written: Guido (father of Python, benevolent dictator) decided not to be backward compatible in the process of designing Python3, under the influence of an article "Python warts", otherwise most defects could not be fixed. Then Python is very popular, and if you want to use Python, you have to follow this idea. Compatibility is a big problem for developers.
Python2 and 3 are so different that incompatibility is understandable, even as two branches, but the difference between 2.6and 2.7is not small. Sometimes the deployment environment is very complicated. For example, the default Python version in the operating system is 2.6, but the minimum requirement in many applications is 2.7, so you have to struggle with this, and you still have to upgrade for the application.
The first step is to download a 2.7 installation package.
Wget http://python.org/ftp/python/2.7/Python-2.7.tar.bz2-- no-check-certificate
The option used for decompression is-j, which is somewhat different from other compressed files.
Tar-jxvf Python-2.7.tar.bz2
Put the extracted Python directory under / user/local.
Mv Python-2.7 / usr/local/
In the source code package, we modify the configuration of zlib in Modules/Setup.dist
Get rid of the comments.
Zlib zlibmodule.c-I $(prefix) / include-L $(exec_prefix) / lib-lz
The remaining step is to compile and install.
. / configure
Make all
If there is a make error at this time
Make: * * [Modules/zlibmodule.o] Error 1
The message shows that it is related to zlib. You have to reinstall a package zlib-devel.
Yum install zlib-devel
This stage is the best, and then it will be very easy.
Make all
Make install
Make clean
Make distclean
After the installation steps are deployed, the current system-level Python is still the default 2.6. we need to modify the default configuration and change the link under / usr/bin.
/ usr/local/bin/python2.7-V
Mv / usr/bin/python / usr/bin/python2.6_bak-- back up the original.
Recreate the soft link
Ln-s / usr/local/bin/python2.7 / usr/bin/python
[root@oel641 Python-2.7] # python-V
Python 2.7
Then there is the part of yum. If the version 2.7 is not compatible with 2.6, we have to modify the yum header to point the version of python to 2.6.
For example, modify the high quality content of the file / usr/bin/yum to
#! / usr/bin/python2.6
Then there are tools like pip.
To install pip, you have to configure setuptools first. Step by step, it's not a hassle.
Wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg-- no-check-certificate
Wget https://bootstrap.pypa.io/get-pip.py-- no-check-certificate-O-| python
However, if you want to install some Python modules later, such as psutil,mysql-connector, there will be problems with yum installation, because yum is based on python 2.6, which is not found in the 2.7library file. One solution is to download the source package and install it.
After a lot of twists and turns, I can finally use psutil, and the configuration of mysql-connector is working.
All that's left is to write some simple scripts or borrowlism and learn from other people's good scripts. Debug it, and then add some customized content on this basis.
After reading the above, have you mastered the method of Python upgrade and compatibility configuration? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.