redhat7.6 default python2.7 installed.
View the installed python case
cd / # root directory to locate whereis python python # view the directory / usr / bin cd / usr / bin directory # cut to python python LL * # python beginning to see the details of the relevant documents
mv python python.bak # backup the original python files.
Installation Python3
In order to avoid various problems missing dependencies, then skip the step of install dependencies end of this document.
# Create a python directory mkdir / usr / local / python3 # Switch to the new directory cd /usr/local/python3 # Download the installation package python3.7 wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz # Unzip package python tar -xvf Python-3.7.4.tgz Change to the directory # Python cd - 3.7 . 4 # Specify python3 installation path / usr / local / python3Dir . / Configure --prefix = / usr / local / python3Dir
the make
the make the install a given case <_>
1. ModuleNotFoundError: No module named '_ctypes' make: *** [install] 错误 1
# Because of the lack libffi- devel dependent, using the following command to install. Yum -Y the install libffi-devel
Continue to re-make install error after installation.
2. zipimport.ZipImportError: can't decompress data; zlib not available make: *** [install] 错误 1
Zlib * # missing dependencies. Yum the install zlib * -Y
3. python3 later installed, will report this error when using the pip.
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
# Openssl version comes as relatively low, you need to install high-devel version of openssl. Yum install gcc libffi * openssl-devel zlib-devel
In this case found that the use yum an error.
-bash: / usr / bin / yum: / usr / bin / python: bad interpreter: No such file or directory
Because yum rely python, just mv python python.bak change the file name so being given back to the file name:
cd /usr/bin/ mv after python.bak python # yum install can be changed using the above dependencies.
# yum finished using the above dependencies installed, be sure to re-python naming back. Otherwise python3 establish connection when you are prompted to file already exists error behind .
cd /usr/bin/
mv python python .bak
After reinstalling the above three dependencies, continue.
the make Clean # clean up the make # probably a few minutes the make install # execution is completed without error had loaded
# Switch to the install directory bin directory: cd /usr/local/python3Dir/bin # establish connection ln -s /usr/local/python3Dir/bin/python3 /usr/bin/python # View python version python - V # Python correspond View details ll /usr/bin/python*
Here python3 is now installed.