gpt4 book ai didi

python - 如何让 Automator 使用 pyperclip 识别 python 脚本?

转载 作者:太空宇宙 更新时间:2023-11-03 15:41:42 25 4
gpt4 key购买 nike

我正在 Mac OSX 10.12.3 中使用 Automator 来利用 pyperclip 运行 Python 脚本。 。我使用 Run Shell Script (/usr/bin/python) 创建了一个 Automator 步骤:

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))

但是,它显示此错误:

ImportError: No module named pyperclip

我可以在终端中执行此代码,为什么 pyperclip 不被 /usr/bin/python 识别?仅供引用,我还安装了 Anaconda。

最佳答案

当我在 Anaconda virtualenv 下安装 pyperclip 时,Automator 正在使用 /usr/bin/python 。当我运行 python 时,我注意到它说:

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.

与 Automator 使用的版本相比,它看起来像是一个不同的 Python 版本。现在我要做的就是:

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

关于python - 如何让 Automator 使用 pyperclip 识别 python 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42056786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com