The terminal directly executes the py file without the python command,

Source: Internet
Author: User

The terminal directly executes the py file without the python command,

Then grant the script file running permission,

Method (1) chmod + x./*. py

Method (2) chmod 755./*. py (777 does not matter)

If this command is not adjusted, the permission denied error will occur.


Run the command directly on the terminal.

If a comment similar to the following is provided at the beginning of the script content:

#! /Usr/bin/env python(Or #! /Usr/bin/python)

Then you can run it directly on the terminal:

./*. Py


Without this comment

Run the following command on the terminal:

Python./*. py


(Note: In some linux versions, you must add python as a command in front of python even if it is commented out above.

Otherwise, if the file./*. py is not a command, the./*. py not found error may occur. That is, this command cannot be found. Of course)

If there is a GUI script

After the previous chmod, double-click it to execute it.

In the above discussion, the terminal directly executes the py file. If you do not need the python command, it means all the content that I want to share with you. I hope you can give us a reference and support the help house.

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.