SyntaxError "invalid syntax"

I keep on getting the error message:

SyntaxError: invalid syntax
>>> & C:/Users/natsu/AppData/Local/Programs/Python/Python313/python.exe "d:/aaPytho\n Files/passwordManager.py"
  File "<python-input-5>", line 1
    & C:/Users/natsu/AppData/Local/Programs/Python/Python313/python.exe "d:/aaPython Files/passwordManager.py"

And my code looks like:

from cryptography.fernet import Fernet

'''
def write_key():
    key = Fernet.generate_key()
    with open("key.key", "wb") as key_file:
        key_file.write(key)'''

def load_key():
    file = open("key.key", "rb")
    key = file.read()
    file.close()
    return key

master_pwd = input("What is the master password? >> ")
key = load_key() + master_pwd.encode()
fer = Fernet(key)

def view():
    with open('passwords.txt', 'r') as f:
        for line in f.readlines():
            data = line.rstrip()
            user, passw = data.split(" ")
            print("User:", user, "| Password:", str(fer.decrypt(passw.encode())))

def add():
    name = input('Account Name: ')
    pwd = input('Password: ')

 
    with open('passwords.txt', 'a') as f:
        f.write(name + "|" + str(fer.encrypt(pwd.encode())) + "\n")

while True:
    mode = input("Would like to add a new password or view existing ones (view, add)? ").lower()
    if mode == "q":
        break

    elif mode == "view":
        view()
    elif mode == "add":
        add()
    else:
        print("Invalid mode.")
        continue

Does anybody know what this means? My code seems fine since I’m following a tutorial.
I’m running Python version 3.14.0 on VS code.

UPDATE: The same problem happens for all other files that I try to run on VS code.

Don’t run it in a Python REPL(that shows >>> before your cursor when you typed python in your terminal), but directly run the command in the terminal(the input window under TERMINAL tab in VS Code)

Hello,

here is a nice trick. Go to File Explorer and search the folder / directory where you have your test script - the one that you posted. Click the File Explorer entry at the top - it should get highlighted in blue (I am using Windows 11). Type cmd to overwrite the directory path of your script path that was highlighted and hit enter. A command terminal window will appear with the script path as the default. Now you don’t have to include it along with the module name when running it. Type the following and hit enter:

python my_script_name_here.py

Your script should run.

Thank you for the responses. I ended up just completely restarting the file and also resetting the .txt files and it seemed to work properly. I’ll try these methods in the future if/when it happens again.