I was writing a code in which the user would run a python program on the Terminal ( I am using OSX ) and the program would copy the username’s password to the clipboard.
Here’s the code:
import sys
import pyperclip
passwords={'AaruDon':'zxcvbnasdjl@!#@!#4324(3’,’Sandy’:’qjljeqkjleq’} # AaruDon and Sandy are usernames that the user might input in the Terminal
idd=sys.argv[1] # idd would be the username that the user will put in the terminal while he is opening the program
if str(sys.argv[1])in passwords.keys():
pyperclip.copy(str(passwords[idd]))
print(' The password has been copied to the clipboard')
else:
print('Sorry. There is no such username.')
When I run this program I get:
ImportError: No module named pyperclip
Believe me, I have imported pyperclip in some older program before and it did work! I don’t know why is it throwing this error if I try to run this from the Terminal!
How do I get rid of this?
NOTE: Pyperclip is installed. I have checked it before too
EDIT 1) I ran another program in the Terminal which also used pyperclip and it did work! The problem is with this program only
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…