notepad++ running Python

Source: Internet
Author: User

notepad++ is an open source text editor, powerful and easy to use, in general, notepad++ as a code viewer, very convenient, but every time to run, always need to right-click on the other IDE to compile and run, always some inconvenient.

Configuration of Python

First, configuration:

1. Open notepad++:

2. Press F5, or Open run ... (e.g.:)



Pop-up Run window


3. This step is the most critical, copy and paste the following statements into the input box:
cmd/k python "$ (full_current_path)" & PAUSE & EXIT
Click Save ...

 

4. Settings in the shortcut window:

Shortcut window just to set shortcut keys for running this command

where name can be entered casually (for example: Run Python),

Shortcut keys can also be selected, the only rule is not to conflict with the set, otherwise it will not work, and this shortcut can be modified, so there is no need to worry (such as CTRL+F5).

When you are finished setting up, click OK to save this command.


5. Close run ... Window

 

6. Test whether the setting is successful.

write down the python statement (this is the Python 2.x syntax):

Print "Hello world!"


7. Save As. py


8. Press Ctrl+f5on notepad++ and the result is as follows:

can be seen, run successfully, pop-up window for Command Prompt window  Second, the principle: 

cmd/k python "$ (full_current_path)" & PAUSE & EXIT

 

The meaning of cmd/k is to execute the following command, and to keep the window after execution is complete. (that is, cmd means to open the Command Prompt window and run the commands behind/k-python)

cmd/k python = = start –> run –> input cmd–> input python

$ (full_current_path) means the full path of the current file, which is the notepad++ macro definition

& is to connect more than one command

Pause indicates the end of the run and waits for an arbitrary key

Exit means close the command-line window (you can omit EXIT if you use cmd/c). )

 third, error and analysis: reasons for not working under normal circumstances:

1. Python not installed

2. Environment variables for Python not set

To verify that Python's environment variables are not set:

Start-to-run input cmd–> input Python

If Python is not an internal or external command, it means that there are no environment variables configured for Python.

 workarounds that normally do not work:

1. Install Python

2. Copy the Python installation directory to path. Method:

example, the installation directory is: C:\PYTHON25

1>. Right-click Computer, properties–> Advanced, Environment Variables

2>. Locate path in system variables, double-click Path, and C:\Python25 paste in the Variable value text box. (Note: Paste at the end, separated from the preceding content with a semicolon.) Do not overwrite other content, otherwise it will not be available to other software. )

3>. Save it.

 Verify that the python environment variable is set successfully:

Start-to-run input cmd–> input Python

In the case of Python versions and other information, the start of the tangent input character becomes >>>, which means the configuration was successful

 If you configure an environment variable or no longer run in notepad++, you need to check spelling for errors. For example, if/k is entered as \k, other input errors are made.

Because, cmd/k python "$ (full_current_path)" & PAUSE & EXIT statements are equivalent to running in command prompt using commands, if you manually enter in command prompt to run , then the question is spelled ...

 Four, the shortcut key modification method: 

1. On notepad++, select Settings, Shortcut Mapper ... to open the Shortcut Mapper window:

 

2. Enter the Run Commands tab:

here, you can see in the 4th step, set the name of the run Python with shortcut.

Double-click , or Select line –>Modify

in the pop-up shortcut window, you can modify the shortcut keys

notepad++ running Python

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.