1. check the current
Python Version
#python
-V
or
#python
--version
2. Download Python
from FTP, https://www.python.org/ftp/python/
3. unzip the tar.gz
file
#tar
-xvf Python-3.7.0a4.tgz
4. Install gcc++
compilar if needed.
#rpm
-qa |grep gcc
#yum
install make gcc gcc-c++
#rpm
-qa |grep gcc
libgcc-4.8.5-16.el7_4.1.x86_64
gcc-4.8.5-16.el7_4.1.x86_64
gcc-c++-4.8.5-16.el7_4.1.x86_64
5. Confiure it
#
cd /Python-3.7.0a4
#./configure
6. Compile it
#./make & make install
7. Now
you can access Python 3.7
#python3
8. You
also can change the symbolic link for python
#mv /usr/bin/python /usr/bin/python.bak
#ln
-s /usr/local/bin/python3 /usr/bin/python
You also have to change the followings as
you have change the default path for python.
#
vi /usr/bin/yum
#vi
/usr/libexec/urlgrabber-ext-down
Change " #!/usr/bin/python" into "#!/usr/bin/python2"
Now you have upgraded python successfully. You
can input "python" to access python 3 and input "python2"
to access python 2.
You may
encounter the following error when compile the file.
ERROR 1:
zipimport.ZipImportError:
can't decompress data; zlib not available
make: *** [install]
Error 1
Solutions: #yum install zlib*
ERROR 2:
ModuleNotFoundError:
No module named '_ctypes'
make: *** [install]
Error 1
# rpm -qa |grep
libffi
libffi-3.0.13-18.el7.x86_64
[root@nbu773srv1
Python-3.7.0a4]# yum list |grep libffi
libffi.x86_64
3.0.13-18.el7
@anaconda
libffi.i686
3.0.13-18.el7
base
libffi-devel.i686 3.0.13-18.el7 base
libffi-devel.x86_64 3.0.13-18.el7 base
Solutions: #yum install
libffi-devel.x86_64
No comments:
Post a Comment