Why can't Notepad++ access the file and how can I run my code?

50 Views Asked by At

I installed a NppExec Console with the language Python on Notepad++, so I could run my code there but it doesn`t work. My code is correct but Notepad++ can´t open the file of my Program.

# coding: utf—8 —*—
"""
Created on Fri Feb 23 23:28:00 2024
@author: marie
"""

print("Aufgabe 3: ")

def schluesse1Hinzufuegen (inventar):
    inventar.append("Schluessel")

inventarMar1ey=("Buch", "Lampe", "Dolch")                 # tuple erstellen
print ("\n", inventarMar1ey)
Marleylist=list(inventarMar1ey)                           # in liste umwandeln
schluesse1Hinzufuegen(Marleylist)                         # E1ement hinzufügen
inventarMar1ey=tuple(Marleylist)                          # in tuple umwandeln
print("\n", inventarMar1ey)                               # tuple ausdrucken

this is what the NppExec Console says after I execute my Program:

NPP_EXEC: "Run Python"
NPP_SAVE: C:\Users\marie\OneDrive\Schule\Informatik\3-Weitere Konzepte\3-Listen,Tupel,Mengen,GefroreneMengen\Listen, Tupel, Mengen und eingefrorene Mengen.py
CD: $ (CURRENT_DIRECTORY)
Current directory: C:\Program Files\Notepad++
python Listen, Tupel, Mengen und eingefrorene Mengen.py
Process started (PID=5980) >>>
**python: can't open file 'C:\\Program Files\\Notepad++\\Listen,': [Errno 2] No such file or directory**
Process finished (PID=5980). (Exit code 2)
READY ================

Now what botters me is line 8. The picture of my Problem

Thats the tutorial what I followed: https://youtu.be/6J8gXEu_IpE?si=2zGPdoI9fnyfQKHQ

Even if I type something like

print("hello")

the same problem appears.

Now my question is how can I run my code without this problem?

1

There are 1 best solutions below

0
help-info.de On

Edit:

The short story - your file name contains spaces. Change the Python call in your NppEXEC script to python "$(FILE_NAME)" or avoid spaces.


As you have already mentioned, your code is without errors and is working in my environment (without spaces in file name (!), see console in the screenshot below). Please check your installation and environment. You may want to check Set up Notepad++ to run Python Script (for you toogle German).

In Notepad++ Settings > Preferences > Default Directory set to ☑ Follow current document.

From the main menu click on Plugins > NppExec and set the following options as shown in the screenshot below:

  • Show NppExec Console
  • No internal messages
  • Follow $(CURRENT_DIRECTORY)

The Follow $(CURRENT_DIRECTORY) menu item makes it run the scripts from your current working directory.

enter image description here