我发现了关于华为移动路由器的有趣文章: https : //blog.hqcodeshop.fi/archives/259-Huawei-E5186-AJAX-API.html 在第二条评论中,一个名为 rvl 的人提供了他的脚本,以便在需要时通过 API 自动重启。
我试图自己修复缩进。这是一个结果http://pastebin.com/KqF5RsS0 我不确定它是否正确。甚至不确定我应该使用哪个版本的 Python 来运行它。
sabbath@dell ~> /usr/bin/python2 router-reboot-script.py
Traceback (most recent call last):
File "router-reboot-script.py", line 6, in <module>
import requests
ImportError: No module named requests
或者
[sabbath@dell ~]$ python -m router-reboot-script.py
/usr/bin/python: Error while finding spec for 'router-reboot-script.py' (AttributeError: module 'router-reboot-script' has no attribute '__path__')
我没有 Python 技能。有人可以帮我弄清楚如何运行它吗?
编辑
[sabbath@dell ~]$ sudo pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python3.5/site-packages
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[sabbath@dell ~]$ sudo pip install --upgrade pip
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 686kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Successfully installed pip-9.0.1
[sabbath@dell ~]$ sudo pip install requests
Requirement already satisfied: requests in /usr/lib/python3.5/site-packages
[sabbath@dell ~]$ python -m router-reboot-script.py
/usr/bin/python: Error while finding spec for 'router-reboot-script.py' (AttributeError: module 'router-reboot-script' has no attribute '__path__')
[sabbath@dell ~]$ python router-reboot-script.py
我应该使用哪个版本的python,我应该使用什么样的参数(如-m)?