• Login
Community
  • Login

ImportError: No module named Npp

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 2 Posters 2.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H
    HealPotion
    last edited by May 30, 2018, 8:10 PM

    import os;
    import sys;
    from Npp import notepad

    filePathSrc=“M:\server”

    for root, dirs, files in os.walk(filePathSrc):
    for fn in files:
    if fn[-4:] == ‘.yml’:
    notepad.open(root + “\” + fn)
    notepad.runMenuCommand(“Encoding”, “Convert to ANSI”)
    notepad.runMenuCommand(“Encoding”, “Encode in ANSI”)
    notepad.save()
    notepad.close()

    Process started (PID=124000) >>>
    Traceback (most recent call last):
    File “ansi.py ”, line 3, in <module>
    from Npp import notepad
    ImportError: No module named Npp
    <<< Process finished (PID=124000). (Exit code 1)

    C 1 Reply Last reply May 30, 2018, 8:16 PM Reply Quote 1
    • C
      Claudia Frank @HealPotion
      last edited by May 30, 2018, 8:16 PM

      @HealPotion

      did you run the script via NppExec plugin?
      You need to use PythonScript Plugin to have access to the notepad object

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 1
      • H
        HealPotion
        last edited by May 30, 2018, 8:48 PM

        How do I run the script through NppExec?

        Thanks for the response.

        C 1 Reply Last reply May 30, 2018, 8:50 PM Reply Quote 1
        • C
          Claudia Frank @HealPotion
          last edited by May 30, 2018, 8:50 PM

          @HealPotion

          you can’t - NppExec does not know anything about Npp - you need to use Python Script plugin as this plugin is creating and exporting the Npp namespace.

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 1
          • H
            HealPotion
            last edited by May 30, 2018, 9:18 PM

            Thank you!

            This problem is solved.

            1 Reply Last reply Reply Quote 0
            3 out of 5
            • First post
              3/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors