Python in Ubuntu system

  UbuntuIn the system, Python version 2.7.x is installed by default, and python command is executed directly. Pthon version 2.7.x will be opened; Python version 3 needs to be installed by itself, and after successful installation, Python 3 will open pyt.Hon 3.x version.

  pythonIt is installed in the /usr/bin directory; the python library is installed in /usr/local/lib/python XX. XX is the version number.

  This article introduces the installation of Python source code in Ubuntu system:

        Official website download source: WGet https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.gz

        Decompression source package: tar -zxf Python-3.5.2.tar.gz

        Compile: CD Python-3.5.2

                ./configure  –prefix=/usr/local    # –prefix=/usr/localSpecify installation directory

                make && sudo make install

  By modifying the soft connection and directly executing the python command, you can open the python 3.x version:

        sudo unlink /usr/bin/python

        sudo ln –s /usr/bin/python3.5 /usr/bin/python        # Specify python3.5 version

 

  UbuntuIn the system, there are two ways to execute Python files:

    1.  python/python3    test.py        When there is Chinese in the python 2 file, you need to add # coding = UTF-8 or # – * – coding: UTF-8 – * – (recommended) at the beginning to solve the problem of unsupported Chinese encoding, but not in the python 3 file.

    2.  ./test.py    In this way, the python file starts with either \!/ usr / bin / Python or !/ usr / bin / Python 3, indicating where the Python interpreter is located.

Leave a Reply

Your email address will not be published. Required fields are marked *