簡體   English   中英

在 shell /bin/bash 中運行 Python 3 腳本時 Automator 出現 importError

[英]importError in Automator while running Python 3 script in shell /bin/bash

我正在嘗試使用 shell /bin/bash 將我的 python3 腳本添加到 Automator,但不斷收到錯誤消息:

"ImportError: No module named watchdog.observers”"

我認為這是因為它運行 Python 2 而不是 3。在互聯網上搜索后,我想出了以下./bash_profile 和 shebang 行,但它似乎仍然不起作用。 這就是我對自動機感到厭倦的地方:

自動機

這就是我的 bash_profile 的樣子: bash_profile

最后這就是 Python 腳本中的第一行的樣子: Python 3 腳本

然后當我運行 Automator 時,我收到以下錯誤消息:

錯誤信息

為什么我會收到導入錯誤,我該如何解決?

好的,那我解決了。 在 Automator (shell /bin/bash) 中,我做了:

/Users/username/Documents/categorize_downloads.py

在此之前,我對要運行的文件具有更改權限,因此:

chmod 755 filename

最后我將shebang更改為:

#!/usr/local/bin/python3

似乎可以使用“env python3”代替,但在這種情況下,我必須刪除“env”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM