在安装mechanize后,我似乎无法导入它。
我已经尝试从pip、easy_install和通过python setup.py从这个repo安装:https://github.com/abielr/mechanize。所有这些都无济于事,因为每次我输入Python交互时,我得到:
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mechanize
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mechanize
>>>
我之前运行的安装报告已经成功完成,因此我希望导入能够正常工作。是什么导致了这个错误?
我在系统上安装2.7和3.5时遇到了这个问题,试图用Python-Telegram-Bot测试电报机器人。
在使用pip和pip3安装后,无论是否使用sudo,我都无法让它工作。我总是得到:
Traceback (most recent call last):
File "telegram.py", line 2, in <module>
from telegram.ext import Updater
File "$USER/telegram.py", line 2, in <module>
from telegram.ext import Updater
ImportError: No module named 'telegram.ext'; 'telegram' is not a package
正确地读取错误消息告诉我,python正在当前目录中查找telegram.py。我有一个脚本叫telegram。py当我调用import时,它被python加载了。
总结,确保在尝试导入时,当前工作目录中没有任何package.py。(并仔细阅读错误消息)。