Python3 Linux Installation (Redhat)

Source: Internet
Author: User
Tags install openssl python script

Python3 Linux Installation (Redhat):

    • Download python-3.6.4.tgz:

https://www.python.org/downloads/release/python-364/

    • Yum Install dependent packages (varies per machine)

Yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel//installation of possible dependent libraries

    • To install Python:

TAR-ZXVF python-3.6.4.tgz

CD python-3.6.4/
./configure--prefix=/usr/local///install to/usr/local directory
Make
Make Altinstall//cannot be installed here, because install does not differentiate version, there will be multiple version confusion problem

Execution file for python3.6 program:/usr/local/bin/python3.6
python3.6 application directory:/usr/local/lib/python3.6
PIP3 execution File:/usr/local/bin/pip3.6
Pyvenv3 execution File:/usr/local/bin/pyvenv-3.6

    • To modify a soft link:

Cd/usr/bin

MV Python Python.backup
Ln-s/usr/local/bin/python3.6/usr/bin/python
Ln-s/usr/local/bin/python3.6/usr/bin/python3
Rm-rf/usr/bin/python2
Ln-s/usr/bin/python2.6/usr/bin/python2

    • Yum Dependency Issues

Installing a high version of Python will result in Yum not being used, yum is dependent on Python, and Yum will not be able to use it directly after installing Python3, with the following error, which requires a direct designation of the interpreter that modifies the Python script in Yum.

Modify the header files for the/usr/bin/yum and/usr/bin/usr/bin/urlgrabber two files, and change the first line #!/usr/bin/python to #!/usr/bin/python2

Run yum install gcc again, everything is OK, haha.

    • To install a third-party package:

Https://pypi.python.org/pypi?%3Aaction=search&term=pyperclip&submit=search

Download via pip3.6:

pip3.6 Install PyPDF2

To the third-party installation path check:

    • Test:

Create firstpythonscript.py

# !/usr/bin/python3 Import  = open ('sbt.in.action.2015.11.pdf'rb'  = Pypdf2.pdffilereader (pdffileobj)print= pdfreader.getpage (+)  Print(Pageobj.extracttext ())

Give Execute permission:

chmod +x firstpythonscript.py

Perform:

Done!

Python3 Linux Installation (Redhat)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.