[英]python script ImportError: No module named 'webbot' when running shell script in Automator
I have a shell script action that has the following command:我有一个 shell 脚本操作,它具有以下命令:
python /Users/my_name/Desktop/webbot/do_something.py
but I get the following error:但我收到以下错误:
Traceback (most recent call last): File "/Users/my_name/Desktop/webbot/do_something.py", line 1, in <module> from webbot import Browser ImportError: No module named webbot
I've ran this python script manually and it works fine, but in Automator I keep hitting this error.我已经手动运行了这个 python 脚本,它工作正常,但在 Automator 中我一直遇到这个错误。 Both pip and python versions are 3.6. pip 和 python 版本均为 3.6。
Edit:编辑:
The python script python 脚本
The shell script + traceback of error message shell 脚本 + 错误信息的回溯
I have checked where pip installs my packages and webbot is with all the other ones.我已经检查了 pip 安装我的包的位置,并且 webbot 与所有其他包一起安装。 I tried importing other packages in the python script and running it in Automator and packages like matplotlib work fine.我尝试在 python 脚本中导入其他包并在 Automator 中运行它,并且像 matplotlib 这样的包可以正常工作。
Turns out that Automator doesn't use python 3.6 by default and therefore it wasn't able to find the modules pip installed in the 3.6 folder.事实证明,Automator 默认不使用 python 3.6,因此无法找到安装在 3.6 文件夹中的模块 pip。 Following this link's answer Specify which version of Python runs in Automator?按照此链接的答案指定哪个版本的 Python 在 Automator 中运行? it shows how you specify to Automator which python version to use before then running the python script.它显示了在运行 python 脚本之前如何向 Automator 指定要使用的 python 版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.