Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
339 views
in Technique[技术] by (71.8m points)

How can I run a python fie written in atom editor directly in Terminal?

I am new to atom editor. I was wondering if by a single command I can directly run the file in the command prompt?
For example in Sublime Text 3, I made a custom Build system where I wrote these lines

{
    "cmd": ["python", "$file"],
    "file_regex": "^[ ]*File "(...*?)", line ([0-9]*)",
    "selector": "source.python",
    "target": "console_exec"
}

Now just by ctrl+b the cmd opens up and the codes executes.
How can I do this in atom?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There many ways to run an atom written python file in the terminal.
The most common way to do this is to run it using python3 in the command prompt.

  1. Save your python file as .py
  2. Use cd to enter the directory with the python file
  3. If on python 2 run: python script_name.py
    If on python 3 run: python3 scrip_name.py

You can also use extensions to make this easier. Atom is a text editor, not an IDE, however certain extensions can provide some IDE capabilities to Atom. One of them is the atom-python-run extension. Here is the installation instructions and documentation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...