1

I am using Python 3.3 (2.7 is also installed) and a compatible version of pygame. Recently I have been trying to switch from IDLE to Notepad++

I am using a saved shortcut in Notepad++

    C:\Python33\python.bat "$(CURRENT_DIRECTORY)" "$(FILE_NAME)"

which runs the batch file:

    @echo off

    cd %1
    %2

    if not errorlevel 1 goto quit
    echo.
    echo.
    pause
    :quit

When I run C:\Python33\Foldername\imp_prob.py

    import pygame

in IDLE it works fine, in Notepad++ using that shortcut it gives an ImportError: No module named pygame

My questions are:

  1. Why is the NP++ method not producing the same result?
  2. How can I change the shortcut or batch file to make it run stuff that IDLE can run?
  3. What method can I use to ensure that I can import a module regardless of which directory I am running the program from?

edit: a working alternative was in the answers to How do you run a python script from within notepad++?

I had some issues with the code they provided, but replacing "python" with the full path to my python33 install solved that.

I still don't understand why pygame wouldn't import when using my run shortcut. I also don't understand why NppExec works when Run doesn't.

Community
  • 1
  • 1
Age
  • 11
  • 3

1 Answers1

0

It sounds like you would need to set your systemvariables. Idle does not require these steps. You entered the full path to the python.exe in np++ to execute the python program, but the path to the modules etc. is still unknown.

Add the paths, and try again.

System Properties -> Advanced -> Environment Variables, in the bottom window look for a "Path" variable, Edit and append the following the existing entries (do not delete anything in there!)

;C:\Python33;C:\Python33\DLLs;C:\Python33\Lib

for Python 3.3, if you have installed it into its default directory.

To see if everything worked, open the console anywhere (shift+rightclick -> Open Command Window Here) and just type "python". The python console should open, telling you that you use python 3.3. You then also do not need to tell np++ the full python path, but instead can just use "python" again.

user1451340
  • 387
  • 1
  • 4
  • 12