当它导入像 shodan 这样的库时,如何从 linux 终端 运行 python 脚本?

How to run a python script from linux terminal when it imports libraries like shodan?

root@kali:~# ./collecting_info_using_facets.py apache 
Traceback (most recent call last):
  File "./collecting_info_using_facets.py", line 3, in <module>
    import shodan
ImportError: No module named shodan

我将路径包含为 #!usr/bin/env python 但是我也无法从命令行导入 shodan 但我可以 运行 来自 python3 IDLE 的相同程序。

这是因为您需要下载名为 'Shodan' 的 Python 模块。您似乎没有安装它,这就是 Python 返回错误的原因:ImportError: No module named shodan

您可以通过以下方式为 Python3 安装 Shodan:

pip3 install shodan

或者如果您是 运行 Python2,请尝试:

pip2.7 install shodan

祝你好运。