I am very new to Python and I am going through the "Automate the Boring Stuff with Python" book (https://automatetheboringstuff.com/chapter6/). I am working on the Password Locker project and having difficulties with the pyperclip module. I am running Python 3.6.2 on Mac OS X Yosemite.
When I try to run my program through terminal I receive this message:
Traceback (most recent call last):
File "./pw.py", line 8, in <module>
import sys, pyperclip
ModuleNotFoundError: No module named 'pyperclip'
However, I have already installed pyperclip and receive this message when I try using "pip3 install pyperclip":
pip3 install pyperclip
Requirement already satisfied: pyperclip in
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
and it works fine for me in Shell:
>>> import pyperclip
>>> pyperclip.copy('hello')
>>> pyperclip.paste()
'hello'
I believe my program is identical to that in the book aside from the actual passwords:
#! /usr/bin/env python3
# pw.py - An insecure password locker program.
PASSWORDS = {'email': '12345',
'blog' : '54321',
'luggage': '123456789' }
import sys, 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)
I've been trying to find out why this happens, but cannot figure it out. Again, I am very new to Python and any helpful insight would be much appreciated! Thanks!