Getting Started with Python (i)

Source: Internet
Author: User

I. Modifying the Python version of Linux

Use commands to view Python versions

ls/usr/bin/python*

View the default Python version information

Python--version

1. User-modified version of Python

To modify a Python version for a specific user, simply create an alias in its home directory. Open the user's ~/.BASHRC file and add

Alias python='/usr/bin/python3.4'

Effective: Reload. BASHRC $. ~/.bashrc

2. Download the new Python

(1). Download the source package,,https://www.python.org/ftp/python/

(2). Unzip and enter the source file

(3). Compile and install

./configure
Make all
Make install

(4). View version

/usr/local/bin/python2.7-v

(5). Modify the default Python version

  mv /usr/bin/python /usr/bin/python2.6

     ln - s / usr / local / bin / python2. 7 / usr / bin / pythonTwo. HelloWorld python internal implementation process Python internal execution process is as follows: (1). Executing a python file if you call to another file, the __pycache__ folder is created in the current directory to hold the PYc file. (2). The interpreter is added at the top of the
#!/usr/bin/env python

(3). Content Encoding (PY2)

At the top of the py2, you need to add the following:
#-*-coding:utf-8 -*-

However, the py3 is brought into the input by default

Getting Started with Python (i)

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.