【问题标题】:How to run a python script from linux terminal when it imports libraries like shodan?导入像shodan这样的库时如何从linux终端运行python脚本?
【发布时间】:2018-06-04 09:08:33
【问题描述】:
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模块吗?
  • 你确定你运行的是python3而不是2吗?看来您可能已经为 python3 安装了 shodan 库(因此 IDLE 可以运行)但不是为 2(我怀疑您在命令行上运行)。

标签: python python-3.x command-line-arguments shodan


【解决方案1】:

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

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

pip3 install shodan

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

pip2.7 install shodan

祝你好运。

【讨论】:

  • 我已经安装了它,但我认为问题与命名空间配置有关。
  • 您使用的是什么版本的 Python?此外,这是一个导入错误。您没有为您的特定 Python 版本下载它。
  • 我正在使用 Python 3。bdw 现在已解决。由于某种原因,我格式化了我的操作系统,然后当我使用python -m pip install shodan 重新安装它时,它现在可以工作了。
猜你喜欢
  • 1970-01-01
  • 2018-05-04
  • 2023-03-30
  • 2020-11-27
  • 2021-07-31
  • 2016-07-23
  • 2021-01-09
  • 1970-01-01
  • 2021-01-08
相关资源
最近更新 更多