Fail to setup Notepad++ and Python
Hellmut Kohlsdorf last edited by
Hi friends, I have tried to setup Notepad++ as my default editor for Python programming following the instructions on a couple of youtube tutorials. For you to be able to help to identify my problem you will need information about my setup.
I do run a Windows 7 Ultimate 64 bits computer. I am trying to do the setup of notepad++ 6.8.8.
I have updated the path environment of Windows 7 to include a path to the Python.exe program. As I have installed in parallel Python 27 and Python 35 so my 2 entries in the environment variables section are:
On my drive C:\ in the root level are 2 folders named accordingly “Python27” and “Python35”
In both the Python27 and the Python35 folder there are the executable “python.exe”.
The tutorial that teaches about setting up “Notepad++” for use with Python version 3 after the following setups within Notepad++ not only the editor window of the file "HalloWelt.py should remain visible, but also the command window that is said to be irrelevant to confirm the right setup, but also a window that shows the screen of the Python interpreter that after the initial 2 lines shows the expected “>>>” within the Notepadd++ envirnoment.
I do have selected under the “language” tab Python and I have created 2 entries in the “Run” tab, called “Python35” and “Python27”. I think that’s all I have done so far, but I also do realize that the editor window in Notepad++ does not color the code example I have entered from the youtube tutorial, but it recognizes the instruction and adds brackets and so on, I have also set under the Settings-Tab the current directory as being the one I have displayed in the editor window. Also the file I do save it before selecting either the “RUN” or the specific Python executable visible under the same tab! All what happens is that a command window opens, the selected Python interpreter is executed, but it does not execute the program in the editor window which has been saved to. For me it looks like being the Python command line editor being opened!
Claudia Frank last edited by Claudia Frank
Hello Hellmut Kohlsdorf,
I don’t know which youtube video you are referring to
but I want to show you another way how to get in
python programming using notepad++ (npp).
The steps which need to be done are
- Install the python package of your choice
- add NppExec plugin via Plugin Manager
- Configure NppExec to run your python scripts.
Some basics about npp first.
Npp recognise the language by the file extension registered
or by selecting the language via the menu Language.
Registered extensions are .py .pyw, which means
whenever you open a file with this extension npp
choose python lexer to do colouring. If you create a new
script npp can’t know which lexer needs to be choosen until
you save the file and name it or by choosing the language manually.
So I do normally create a new file and immediately afterwards save it,
then start coding.
Step 1 has been already done by you - ok.
Step 2 add NppExec plugin via Plugin Manager
Why choosing NppExec, at first glance NppExec does things similar to
the built-in Run feature but it has additional features which I wouldn’t miss anymore.
When using the Run feature you can specify the program which should be
executed and the parameter, basically that’s it and it’s ok if you don’t need more.
NppExec does the same but allows you to interact with the generated output and npp.
We will see what I’m talking about in a minute.
Let’s start with step 2.
Choose Plugins->Plugin Manager-Show Plugin Manager
A window with 3 tabs (Available, Updates, Installed) appear.
Select Available, which normally is already selected, and scroll
down the list of available plugins. Check NppExec and press Install.
The download of the plugin starts and once finished the installation begins.
Normally you will be asked to restart npp so that the plugin can get loaded.
If this step has been done press F6 and the NppExec window should appear.
If this is the case, installation was successful. If not, we need to find out what went wrong.
With the opened NppExec window step 3 starts but before we do this we close the window
by pressing the cancel button.
We prepare the first python script.
Open a new document and save it with the name you want.
Put in the following line into the document.
print 'Hello world'
Save it (STRG+S).
Press F6 and put the following into the Execute… window
Now you should either see the “Hello world” in the conosole window or
an error (even if you followed the instruction carefully), because
it depends which python interpreter has been found first.
Python3 doesn’t allow that syntax anymore whereas it is correct in Python2.
That means we need to adjust the NppExec call. Press F6 again
and change the command, the last one should be still visible, to
cd C:\Python27 python "$(FULL_CURRENT_PATH)"
press save and give it a meaningful label.
Do the same for Python35 by change the lines accordingly and save with different name.
cd C:\Python35 python "$(FULL_CURRENT_PATH)"
We need to cd (change directory) first to allow python to find its module
otherwise it could happen that Py2 tries to load modules from Py3,
or vice versa, which CAN but must not work.
The $(FULL_CURRENT_PATH) resolves always to the active document,
so be sure that you have the python script opened.
The surrounding double quote is to prevent gaps misunderstanding in the path.
For example if the path would be
C:\Documents and Settings\...\my_pyscript.py
python interpreted would assume that the Script is C:\Documents and
the and and then Settings… are parameters for that file.
One additonal configuration. As said the provided python example runs under
Py2 only and throws an error if using Py3.
Wouldn’t it be nice to be able to click on the error and you will be automatically
directed to the line which has been reported as faulty.
This can be achieved be setting NppExec console filters.
select Highlight tab
check the first box and
put the following line into it
*File "%ABSFILE%", line %LINE%
give a color like 0xFF 0x00 0x00 mark Bold etc… or leave it.
Run the same script with Py3 again, now we should see an error.
Double click on the File… line… line and the erroneous line
will be marked in your source script.
Basically that’s it. If you want to execute more than one python script at the same
time you need to copy/paste NppExec.dll with different names but I guess that is
Hellmut Kohlsdorf last edited by
Dear Claudia, many thy for this detailed response. I will apply it later and will let you know if everything went well or if I do still run into a problem!
In one of the videos I was studying they used the string you mention, “$(FULL_CURRENT_PATH)”. Where can I find documentation that explains not just that string but all the kind of stuff like that! This afternoon I was searching for that kind of information via Google.
The course to which I want to apply the information you have just given to me is the course offered via Coursera, Python for Everybody from the university of Michigan. I am at week 4 and I was using Visual Studio 2015 trial were the trial period unfortunately is over! I am learning this so as I am also learning about Linux as I plan toapply design by modeling technology and need to learn by using the raspBerry Pi about how Mathematica from Wolfram does communicate with the RaspBerry Pi and later also how SystemModeler does that too, so that I can apply what I am learning this way to a design for a system to control the sheet in my model sailboat and where I want to resolve some questions by simulating parts of the system using the language Modelica within the Wolfram environment!
Claudia Frank last edited by
wow this sounds interesting. Pi and its clones/derivates are one of the projects
I will do in 2016 too.
Regarding your question, NppWiki and, after installation of NppExec, the NppExec User Guide plus NppExec.txt have this information.
Both can be opened via the Plugins Menu.
And if there are still open questions, this forum of course. ;-)
guy038 last edited by
Brilliant and clear guidelines on Python Script and NppExec plugins installation and their interactions, I backup the link of this post, which should be useful, no doubt, to many people ( and me too ! )