I am trying to complete Appendix B in Automate the Boring Stuff - 'Running Python Programs on Windows' however when I WIN-R the script and argv, I get the error "can't find '__ main __' module in C:\ path.
I have created the .py script as well as the batch file, changed the system variable path but still can't get the program to run from WIN-R.
My script for pw.py is as follows:
#! /usr/bin/env python3
# pw.py - An insecure password locker program.
PASSWORDS = {'email': 'F7min1BDDuvMJuxESSKHFhTxFtjVB6',
'blog': 'VmALvQyKAxiVH5G8v01if1MLZF3sdt',
'luggage': '12345'}
import sys
import pyperclip
if len(sys.argv) < 2:
print('Usage: python pw.py [account] - copy account password')
sys.exit()
account = sys.argv[1] #first command line arg is the account name
if account in PASSWORDS:
pyperclip.copy(PASSWORDS[account])
print('Password for ' + account + ' copied to clipboard.')
else:
print('There is no account named ' + account)
My pw.bat file is as follows:
@py.exe C:\Users\lukev\PythonScripts %*
@pause
When I run pw email in WIN-R, I get the following error:
C:\Users\lukev\AppData\Local\Programs\Python\Python38-32\python.exe: can't find '__main__' module in 'C:\\Users\\lukev\\PythonScripts'
From my research I found out the shebang line shouldn't be as described in the book and should instead be #! /usr/bin/env python3 and another possibility be if I had multiple versions of Python installed however I don't have other versions installed and still have the issue.
Below are screenshots of the python file, the batch file, system environment variables, and error message: