Upgrade Python and Mongodb driver installation under Centos
- 2021-07-09 09:32:52
- OfStack
Look at the version of python python-V if it is below 2.7, it needs to be upgraded.
First go to official website to download the python compressed package you want, and then decompress it. Go to the home directory to do the following (GCC compiler support is required)
./configure --prefix=/usr/local
make all
make install
make clean
make distclean
After executing these commands, in the
/usr/local/bin/
You can see python 2.7 in the directory, and then try to execute
/usr/local/bin/python2.7 -V
If the version number is displayed, the installation has been successful. But the upgrade is only one and a half years old, so you can run python-V again on the terminal and you will find that it is still the version number before the upgrade. Do the following at this time.
Establish a soft connection so that the system default python points to python 2.7
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python
This is when you are running python-V will be your installed version.
The python version upgrade is complete, but you are still a few steps away from it.
At this point, you can try to execute yum list on the terminal, and you will find that the yum command will not work, because yum is not compatible with python 2.7 by default.
We need to modify the/usr/bin/yum file and open it with vim (administrator privileges required).
Object of the file header
!/usr/bin/python
Change to
! /usr/bin/python2.6. 6 This is the file that you modified the link before
In this way, the upgrade of python is basically completed.
Installing MongoDb driver
After installing python, we use it. python sometimes needs a lot of third-party libraries. These libraries need to be installed additionally. The installation tools are mainly setuptools and pip (I won't talk about the difference between these two tools here).
Let's talk about how to install the setuptools and MongoDb drivers offline on the server (our server is definitely not allowed to go to the external network, and it is not allowed in 1 second).
Installing setuptools
Download setuptools-1. 4.2. tar. gz
After unzipping, go to the home directory and execute python setup. py install
If the installation process indicates that the corresponding py package is missing, install the corresponding software package through yum (as follows).
Then recompile and install py, and the installation will be successful if you continue.
Note that 1 will generally lack the following packages
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
After installing setuptools, you can install the driver of mongodb. The method is the same as above.
If you happen to need to install the Python driver for the MongoDB and read the article from back to front, you may be able to avoid installing the python twice.
Summarize