ImportError:无法导入名称WebAPI

2024-05-20 15:26:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用“shodan”API,但它不适合我。在

首先,我在终端easy_install shodan中执行了这个命令 这是我的想法:

$easy_install shodan
Searching for shodan
Best match: shodan 0.8.1
Processing shodan-0.8.1-py2.7.egg
shodan 0.8.1 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/shodan-0.8.1-py2.7.egg
Processing dependencies for shodan
Finished processing dependencies for shodan

然后我写了我的代码:

^{pr2}$

它给了我一个错误:

ImportError: cannot import name WebAPI

我搜索了类似的问题有些答案是更改文件名,有些是删除pyc文件。我试了两个答案,但也不管用。在


Tags: install答案命令api终端forsearchingis
2条回答

我找到了答案 我应该安装py crypto

sudo apt get安装python crypto

你的剧本叫什么名字?如果脚本的名称是“shodan”,即与shodan库同名,则可能会发生名称冲突。python3也有一个问题导致了一些导入问题,但是如果您使用的是shodanapi库的最新版本,那么应该解决这个问题。我附和luc的评论,即缩进看起来是错误的,所以您需要修复它,以便脚本执行。在

相关问题 更多 >