My question is about running a simple mapit python script using the Mac terminal to execute.
I am following along with 'Automate the boring stuff'. I created a script to copy an address either from a website or using text in the clipboard to open a map on google maps. Please see code below.
I have tried to run $ python /Users/.../mapit.py
using the command line but I am encountering the following error message:
Traceback (most recent call last):
File "/Users/.../mapit.py", line 2, in <module>
import webbrowser, sys, pyperclip
ImportError: No module named pyperclip
Despite successfully running pyperclip on the IDLE shell.
I have reinstalled pyperclip using terminal and I have also re-written the script from scratch. I have used pyperclip in the interactive shell and it is working.
Could someone please help me identify where the problem might be?
MAPIT SCRIPT
#!/usr/bin/env pythonw
import webbrowser, sys, pyperclip
sys.argv
# Check if command line arguments were passed
if leng(sys.argv) > 1:
# we know that the address has been passed
address = ' '.join(sys.argv[1:])
else:
address = pyperclip.paste()
# https://www.google.ae/maps/place/<ADDRESS>
webbrowser.open('https://www.google.ae/maps/place/' + address)