Shebang在python脚本之上被忽略,导致导入错误

时间:2019-01-31 16:12:04

标签: python bash apache-nifi shebang

我有一个可在终端机/ jupyter中运行的python网络抓取脚本,并在docker容器中运行。我将shebang放在顶部,指向python的安装位置:

#!/user/bin/python3.5
from bs4 import BeautifulSoup
from os import makedirs
...

但是当我尝试通过该容器运行脚本时(我使用的是NiFi),它没有被拾取,并且得到以下错误列表:

/opt/nifi/nifi-current/python-script/scraper.py: 3: 
/opt/nifi/nifi-current/python-script/scraper.py: from: not found
/opt/nifi/nifi-current/python-script/scraper.py: 4: 
/opt/nifi/nifi-current/python-script/scraper.py: from: not found

为什么不选择脚本? (问的是正确的问题吗?以前不要通过bash运行python)。脚本是否因为以shebang开头而忽略了#?谢谢

1 个答案:

答案 0 :(得分:0)

您可以通过以下方式使用环境发现:

#!/usr/bin/env python3.5
相关问题