When I run this code, the program goes to complete; but nothing has happened. I have no idea what is the problem, suggestions welcome.
New version is Python 3.11.0, Pycharm is 2022.2.4, Old version was 3.7.?? for a 32bit system. This code ran on an older version of Python on an old 32bit laptop.
pwd = input('What is the master password? ')
def view():
with open('passwords.txt', 'r') as f:
for line in f.readlines():
data = line.rstrip()
user, passw = data.split('|')
print('Usr:', user, "| Password:", passw)
def add():
name = input('Account Nmae')
pwd = input('Password')
with open('passwords.txt', 'a' ) as f:
f.write(name + "|" +pwd +"\n")
while True:
mode = input('Would you like to adda new password or view existing passwords?, Enter add or view or Q to quit).lower()
if mode == "q:":
break
if mode == "view":
view()
elif mode == "add":
add()
else:
print("Not a valid code"):
continue
This line will throw a Syntax Error because itâs missing a single quote '.
File "<string>", line 21
mode = input('Would you like to adda new password or view existing passwords?, Enter add or view or Q to quit).lower()
^
SyntaxError: EOL while scanning string literal
Yes thank you, I was missing a quit, however adding the quote in did not change the result. The program stills completes with a 0 error code. It seems to be skipping all the code, the opening input request id not being executed.
The points that @abdnafees has raised indicate that youâre not running the same code that you posted, and possibly not the same code that you think you are running. You could do some good old-fashioned printf-style debugging by adding some prints or intentional exceptions to your code to make sure that youâre definitely running what you think you are, and report back with a direct copy of the code that you ran if youâre still having issues.
You are correct, when I brought the code over from the old laptop the there were differences and I tried to catch them all. I had placed a print(âHelloâ) at the start âbefore the pwd = inputâ and it never got acted on.
Exactly, so I remain unconvinced that youâre running the code you think youâre running
Make sure your changes are saved, double check the file path, look at the file in a third program (not Python, not your IDE, maybe just type), and try again.
You could also try to reduce the whole thing down to just
print('yes, this is it')
1 / 0
in a new file. If that doesnât print yes, this is it and then a ZeroDivisionError traceback with a non-0 exit code, then we need to figure out whether the python.exe youâre using is actually what it should be; try C:\Users\User1\Scripts\python.exe -V, which should give you information about which version of Python is running, and C:\Users\User1\Scripts\python.exe -c "print('hi')" which should just print hi.
Ok, thanks for the pointer. It seems Windows fire wall is blocking some features of Pycharm Community Edition 2022.2.4.
pydev debugger: CRITICAL WARNING: This version of python seems to be incorrectly compiled (internal generated filenames are not absolute)
pydev debugger: The debugger may still function, but it will work slower and may miss breakpoints.
pydev debugger: Related bug: http://bugs.python.org/issue1666807
-------------------------------------------------------------------------------
Connected to pydev debugger (build 222.4459.20)
pydev debugger: Unable to find real location for: <frozen codecs>
Do not use a debugger when you are just starting with Python. Use just the Python interpreter directly from your Windows command line (Power Shell or cmd.exe). Test what Zachary suggested and/or possibly:
Try to call the interpreter without parameters to start an interactive session (REPL). Depending on the way Python was installed on Windows the command to call it can be one or more of:
py
python3
python
Try to execute few python statements in the interactive mode. For example: print('hello')
Quit the interactive interpreter: Ctrl+Z (in Windows)
After that try to run your script: python3 main.py
Intead of python3 use the command which worked in the step 1.
Do not forget to add the path to your main.py file name if you are not in its directory.