1

I want to edit my code in notepad++ and be able to run it from there. However as my script imports library from it's own folder it's proving difficult.

This is what the directory for the script look like \test\test1.py\selenuim\webdriver\firefox etc.

When run by double clicking the file in the explorer it works. When run from notepad using all the methods I could find, it says

Traceback (most recent call last):
  File "D:\test\test1.py", line 1, in <module>
    import selenium.webdriver;
ModuleNotFoundError: No module named 'selenium'

I've already scoured this link: How to Execute a Python File in Notepad ++?

And there is no way to do the way I have in mind. Some include cd in them, however this did not help me.

Mattwmaster58
  • 2,266
  • 3
  • 23
  • 36
  • if the libraries are in the same directory as the module itself, that should work. Can you be more specific? – Jean-François Fabre Apr 17 '17 at 19:24
  • You may want to check [this answer](http://stackoverflow.com/a/3071177/797495) – Pedro Lobito Apr 17 '17 at 19:25
  • What does your directory structure look like? – Ivan Apr 17 '17 at 19:29
  • @PedroLobito Thanks for the suggestion. I tried the plugin, however I got the error `CreateProcess() failed with error code 193: %1 is not a valid Win32 application.` – Mattwmaster58 Apr 17 '17 at 20:04
  • 1
    @PedroLobito Upon further investigation it looks like NppExecute is using CreateProcess() where it should(?) be using ShellExcute() See [here](http://stackoverflow.com/questions/12637203/why-does-createprocess-give-error-193-1-is-not-a-valid-win32-app) – Mattwmaster58 Apr 17 '17 at 20:13

1 Answers1

0

I always use PyNPP plugin for that purpose. I also include the path of my scripts by setting PYTHONPATH. So for instance, if your script resides in C:\test then execute this code in cmd: set PYTHONPATH=c:\test this way Python will be able to locate the location of your scripts.

Once you install PyNPP it's dead easy to use, but make sure you set the right directory path of Python for the plugin from the drop-down menu: plugins -> PyNPP -> options and then select the right path mine is C:\Python27. PyNPP seems to execute Python from the script's location, this eliminates the need to set PYTHONPATH

GIZ
  • 4,409
  • 1
  • 24
  • 43
  • Thanks for the suggestion, but I've already tried that. Triple checked the python directory, still gives me `Couldn't Launch Python. Error code: 193` – Mattwmaster58 Apr 17 '17 at 20:15
  • Have you checked the executable file of Python is working well? Try to run Python from cmd to see if it works. – GIZ Apr 17 '17 at 20:17
  • Yep I do everything I normally would w/ python and yet I can't get this working – Mattwmaster58 Apr 17 '17 at 20:34
  • Are you using 64-bit Python? I think you should try with 32-bit. Looks like you have a similiar problem here: [Error loading Python DLL: python27.dll (error code 193)](https://www.kerstner.at/2012/11/error-loading-python-dll-python27-dll-error-code-193/) – GIZ Apr 17 '17 at 20:54