Following the book 'Automate the boring stuff with Python' I wrote a Python script called mclip.py.
#! python3
# mclip.py - A multi-clipboard program.
TEXT = {'agree': """Yes, I agree. That sounds fine to me.""",
'busy': """Sorry, can we do this later this week or next week?""", 'upsell': """Would you consider making this a monthly donation?"""}
import sys, pyperclip
if len(sys.argv) < 2:
print('Usage: py mclip.py [keyphrase] - copy phrase text')
sys.exit()
keyphrase = sys.argv[1] # first command line arg is the keyphrase
if keyphrase in TEXT:
pyperclip.copy(TEXT[keyphrase])
print('Text for ' + keyphrase + ' copied to clipboard.')
else:
print('There is no text for ' + keyphrase)
When I run this in visual studio code I get:
XXX@XXXs-MacBook-Pro Python Projects % /usr/local/bin/python3 "/Users/XXX/Desktop/Python Projects/mclip.py"
Usage: py mclip.py [keyphrase] - copy phrase text
But following the instructions of the book when trying to run the script from the terminal typing python3 mclip.py $busy I get:
XXX@XXXs-MacBook-Pro ~ % python3 mclip.py
/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'mclip.py': [Errno 2] No such file or directory
It should copy the value of the specific keyword but is not doing so. I am not sure what is causing this problem. Help is much appreciated!
Maybe there could be a problem with the Path VSC is set up with but I am not sure.