UNIX class environment calls Python interpreter

Source: Internet
Author: User

In a Unix-like environment, we always need to invoke the Python interpreter when we write a Python script, usually in the following two ways:

1 #!/usr/bin/python
2 #!/usr/bin/env python

So what's the difference between the two methods of invoking the Python interpreter?

In fact, both of these formulations are right, where #!/usr/bin/python directly tells the operating system to execute this script time, go to the/usr/bin directory to find the Python interpreter. The #!/usr/bin/env python format is designed to accommodate Python's operating system, which is not installed by default in the/usr/bin directory, and when the system reads this type of reference, it looks for the Python installation path in the env settings. Then follow the Python interpreter under the installation path in Env to complete the script operation.

As a result, we should be accustomed to using the second approach when writing scripts so that our scripts or programs can be unblocked in a different UNIX environment for the Python installation directory.



This article is from "Life Beyond" blog, please be sure to keep this source http://cnlinux.blog.51cto.com/6112794/1587973

UNIX class environment calls Python interpreter

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.