1
votes

I'm using Automator in Mac OSX 10.12.3 to run a Python script utilizing pyperclip. I created an Automator step with Run Shell Script (/usr/bin/python):

import pyperclip
import datetime
now = datetime.datetime.now()
pyperclip.copy(str(now.year) + str(now.month) + str(now.day) + '_' + str(now.hour) + str(now.minute) + str(now.second))

However, it is showing this error:

ImportError: No module named pyperclip

I can execute this code in Terminal, why pyperclip is not recognized by /usr/bin/python ? FYI, I also have Anaconda installed.

1
Are you sure that the pyperclip is installed in your machine? - julian salas
how did you install pyperclip? Did you download it and is it a subdirectory of your script? - hansaplast
I can see why: /usr/bin/python in Mac OSX is python 2.7 while I install pyperclip under Anaconda virtualenv. - Dio Phung

1 Answers

1
votes

Automator is using /usr/bin/python while I installed pyperclip under Anaconda virtualenv. When I run python, I noticed it said :

Python 3.5.2 |Anaconda 4.2.0 (x86_64)| (default, Jul  2 2016, 17:52:12) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Look like it is a different python version compared to the one Automator is using. Now all I have to do is:

sudo /usr/bin/python -m pip install pyperclip