模块python-twitter(github)从shell给出错误“没有名为cmdline的模块”

时间:2014-02-07 06:43:10

标签: python shell twitter github module

我刚刚安装了最新的python twitter版本(https://github.com/bear/python-twitter),我收到以下错误。当我尝试从shell使用“twitter”时我得到它...“pip install python-twitter”工作正常,除了它使用过时的api。这个似乎可能会更新,但会抛出以下错误。

错误:

Traceback (most recent call last):
  File "/usr/local/bin/twitter", line 9, in <module>
    load_entry_point('twitter==1.12.1', 'console_scripts', 'twitter')()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 353, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2302, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2029, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
ImportError: No module named cmdline

我很难深入了解造成这种情况的原因。有什么想法吗?

在回复评论时,我正在发布每个步骤的输出,以查看错误仍然存​​在的原因:

1

pip uninstall twitter

回复:

leo@production:~$ sudo pip uninstall twitter
Uninstalling twitter:
  /usr/local/lib/python2.7/dist-packages/twitter-1.12.1-py2.7.egg
Proceed (y/n)? y
  Successfully uninstalled twitter

2

sudo rm -rf /usr/lib/python2.7/site-packages/twitter-1.10.2-py2.7.egg

(静音)

3

wget https://pypi.python.org/packages/source/t/twitter/twitter-1.12.1.tar.gz
tar -xzf twitter*.tar.gz
cd twitter*

(成功的)

3

sudo python setup.py build; sudo python setup.py install

响应:

p.py install
running build
running build_py
running egg_info
writing twitter.egg-info/PKG-INFO
writing top-level names to twitter.egg-info/top_level.txt
writing dependency_links to twitter.egg-info/dependency_links.txt
writing entry points to twitter.egg-info/entry_points.txt
reading manifest file 'twitter.egg-info/SOURCES.txt'
writing manifest file 'twitter.egg-info/SOURCES.txt'
running install
running bdist_egg
running egg_info
writing twitter.egg-info/PKG-INFO
writing top-level names to twitter.egg-info/top_level.txt
writing dependency_links to twitter.egg-info/dependency_links.txt
writing entry points to twitter.egg-info/entry_points.txt
reading manifest file 'twitter.egg-info/SOURCES.txt'
writing manifest file 'twitter.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/follow.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/api.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/twitter_globals.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/ansi.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/stream.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/ircbot.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/timezones.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/auth.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/archiver.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/stream_example.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/cmdline.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/util.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/logger.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/oauth2.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/oauth.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/__init__.py -> build/bdist.linux-x86_64/egg/twitter
copying build/lib.linux-x86_64-2.7/twitter/oauth_dance.py -> build/bdist.linux-x86_64/egg/twitter
byte-compiling build/bdist.linux-x86_64/egg/twitter/follow.py to follow.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/api.py to api.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/twitter_globals.py to twitter_globals.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/ansi.py to ansi.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/stream.py to stream.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/ircbot.py to ircbot.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/timezones.py to timezones.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/auth.py to auth.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/archiver.py to archiver.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/stream_example.py to stream_example.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/cmdline.py to cmdline.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/util.py to util.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/logger.py to logger.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/oauth2.py to oauth2.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/oauth.py to oauth.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/twitter/oauth_dance.py to oauth_dance.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying twitter.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying twitter.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying twitter.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying twitter.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying twitter.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying twitter.egg-info/zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
creating 'dist/twitter-1.12.1-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing twitter-1.12.1-py2.7.egg
Copying twitter-1.12.1-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Adding twitter 1.12.1 to easy-install.pth file
Installing twitter-log script to /usr/local/bin
Installing twitter script to /usr/local/bin
Installing twitterbot script to /usr/local/bin
Installing twitter-follow script to /usr/local/bin
Installing twitter-stream-example script to /usr/local/bin
Installing twitter-archiver script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/twitter-1.12.1-py2.7.egg
Processing dependencies for twitter==1.12.1
Finished processing dependencies for twitter==1.12.1

3 个答案:

答案 0 :(得分:3)

我一会儿得到这个错误。我所做的是完全删除Python Twitter Tools:

    pip uninstall twitter
    sudo rm -rf /usr/lib/python2.7/site-packages/twitter-1.10.2-py2.7.egg

然后我使用以下方法重新安装它:

    wget https://pypi.python.org/packages/source/t/twitter/twitter-1.12.1.tar.gz
    tar -xzf twitter*.tar.gz
    cd twitter*
    sudo python setup.py build; sudo python setup.py install

现在应该可以了。

答案 1 :(得分:2)

发现它!感谢@RydallCooper,我被置于正确的道路上:D

我显然有两个包......

我不得不卸载它们:

pip uninstall twitter

然后:

pip uninstall python-twitter

现在错误消失了:D

答案 2 :(得分:0)

(几年后!)解决方案可能是检查版本

例如如果您使用的是Python 3 Shell,则可能需要使用pip3 install twitter而不是pip install twitter