Python in Notepad++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanjayhpatel2000
    New Member
    • Aug 2007
    • 1

    Python in Notepad++

    Hi Everybody,
    I am new to Python and also new to Notepad++. Can any one help to code my first python program in Notepad++. I am already doing it in python interpretor, but now i was to do in Notepad++. I have already downloaded Notepad++, but still not able to run any python program in it.
    I request any of you to help me start in NOtepad++ with python.
    Thanks
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by sanjayhpatel200 0
    Hi Everybody,
    I am new to Python and also new to Notepad++. Can any one help to code my first python program in Notepad++. I am already doing it in python interpretor, but now i was to do in Notepad++. I have already downloaded Notepad++, but still not able to run any python program in it.
    I request any of you to help me start in NOtepad++ with python.
    Thanks
    The answer to that question is in reply #7 of this thread, but I think that you will find the IDLE is sufficient for your needs for the time being and has much of the things that you will have to work on to get Notepad++ working built in. The aforementioned thread also discusses other IDE options.

    Comment

    • weightlessness
      New Member
      • Feb 2008
      • 1

      #3
      There is a simple way to do it.
      In the Run menu, you can see options like "Lunch in firefox" and more.
      These options are written in a file called shortcuts.xml, located in the folder where you installed NP++.
      Open this file, and inside <UserDefinedCom mands> you'll find this row:
      Code:
       <Command name="launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;$(FULL_CURRENT_PATH)&quot;</Command>
      All you need to do is copy this line and change some things. Then you'll have something like this:
      Code:
      <Command name="Run with Python" Ctrl="no" Alt="no" Shift="yes" Key="112">python &quot;$(FULL_CURRENT_PATH)&quot;</Command>
      (I chose Shift+F1, but you can choose any keys you like.)

      Reopen NP++, and now it's easy and nice to run any python file strait from the editor.
      More information on things like this in NP++: http://notepad-plus.wiki.sourc eforge.net/Run

      Comment

      • yoshco
        New Member
        • Oct 2009
        • 1

        #4
        thanks weightlessness for the direction, you can also try this
        Code:
        <Command name="python+arg" Ctrl="yes" Alt="no" Shift="no" Key="122">cmd /K &quot;$(FULL_CURRENT_PATH)&quot; $(CURRENT_WORD)</Command>
        here i call a command line (with th /k switch so it doesn't close after execution or errors), i also add the CURRENT_WORD for if i want to add arguments (i keep some for debugging as comments in the code).

        note i have python.exe in my PATH so i can call the .py file as is.

        there is no easy way to edit the command once you enter it, i open %USERPROFILE%\A pplication Data\Notepad++\ shortcuts.xml in palin notepad (keep NP++ closed while editing) and play around with the command.

        Comment

        • crisb
          New Member
          • Nov 2009
          • 2

          #5
          Or you could setup NppExec
          Go to Plugins -> NppExec -> Execute (default F6, you can change this)
          Type in the window:
          C:\Python31\pyt hon.exe "$(FULL_CURRENT _PATH)"

          Make sure the path to python.exe actually points to where your python.exe is :)

          Click Save and save it whichever name you want it to be saved as.
          And you're done. Switch between any files you like press F6 then Enter and you've compiled it!

          Happy coding!

          Comment

          • Sean Asemani
            New Member
            • Feb 2011
            • 4

            #6
            Hi

            I'm new to python and notepad++.
            I use python 26 with its shell but I like to use notepad++.
            I also have installed python 27, 31 all in its own directory.(on XP)

            I've read your comment on changing the 'shortcuts.xml' in notepad++ director to enable notepad to run python.
            I did make a change to 'shortcuts.xml' as:

            <Command name="Run with Python26" Ctrl="no" Alt="no" Shift="yes" Key="112">pytho n &quot;$(C:\Pyth on26\EXERCISES\ logistic.py)&qu ot;</Command>

            but it doesn't work at all.
            Could you please tell me what could be wrong?
            If you put correct line for that file, I could just copy and past it into 'shortcuts.xml' file.

            thanks

            Comment

            • Sean Asemani
              New Member
              • Feb 2011
              • 4

              #7
              Hi Crisb

              I've read your comment on how to change the
              Plugins -> NppExec -> Execute in notepad++ in order to run python script and compile it.

              I put the following in NppExec > Execute window as:

              C:\Python26\pyt hon.exe "$(C:\Python26\ EXERCISES\Mepri nt.py)"
              But when I run it I get the following error:

              C:\Python26\pyt hon.exe ""
              Process started >>>
              C:\Python26\pyt hon.exe: can't find '__main__.py' in ''
              <<< Process finished.

              Do you have any idea what could be wrong.

              I've tried it with python 2.7 and 3.1 (which are installed in different folders) but still same error.

              thanks for input.

              Comment

              Working...