【问题标题】:Tweepy installation?Tweepy 安装?
【发布时间】:2021-02-15 04:15:11
【问题描述】:

我尝试使用不同的方法安装 tweepy,例如

  • pip install tweepy
  • sudo pip install tweepy

最后,我从github下载了zip包并使用命令安装:

python setup.py install

显然,安装成功完成,但是当我运行一个只包含一行的简单程序时,例如import tweepy,抛出以下错误:

Traceback (most recent call last):


File "tweepytest.py", line 1, in <module>
    import tweepy
  File "build/bdist.macosx-10.6-intel/egg/tweepy/__init__.py", line 14, in <module>
  File "build/bdist.macosx-10.6-intel/egg/tweepy/api.py", line 12, in <module>
  File "build/bdist.macosx-10.6-intel/egg/tweepy/binder.py", line 11, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/__init__.py", line 53, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/__init__.py", line 27, in <module>
    from . import urllib3
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/__init__.py", line 8, in <module>
    from .connectionpool import (
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 33, in <module>
    from .packages.ssl_match_hostname import CertificateError
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/packages/__init__.py", line 3, in <module>
    from . import ssl_match_hostname
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 3, in <module>
    from ssl import CertificateError, match_hostname
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 90, in <module>
    import textwrap
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 40, in <module>
    class TextWrapper:
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 82, in TextWrapper
    whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
AttributeError: 'module' object has no attribute 'maketrans'

【问题讨论】:

  • 什么操作系统(Linux、*BSD、OS X?)以及您使用的python 版本是什么? sudo pip3 install tweepy 在 LMDE Betsy 上对我来说工作正常。
  • @FredBarclay 我有 OS X (10.11),我的 python 版本是 2.7.9
  • 还有一个问题:您没有使用-pip install tweepy-sudo pip install tweepy(带有破折号)是吗?查看python --version 的输出以检查python setup.py install 是否使用了正确的python 版本也可能很有启发性。
  • @FredBarclay 我尝试使用这两种方法,但都没有奏效:(
  • 不——我在问你是否在命令前使用了破折号。你知道,就像 -pip install tweepy 而不是 pip install tweepy :)

标签: python python-2.7 tweepy


【解决方案1】:

你应该试试

pip3 install tweepy

或者...

pip install git+https://github.com/tweepy/tweepy.git

【讨论】:

    【解决方案2】:

    根据你所说的。我假设您使用的是 python3。您可以通过替换此文件来解决此问题 文件 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py on line 82

    来自

    whitespace_trans = string.maketrans(
    

    whitespace_trans = str.maketrans(
    

    这将使代码编译为 python3 文档。

    【讨论】:

      【解决方案3】:

      还有另一个安装选项,您可以尝试从 GitHub 克隆存储库:

      git clone https://github.com/tweepy/tweepy.git
      cd tweepy
      pip install .
      

      【讨论】:

        猜你喜欢
        • 2014-11-27
        • 1970-01-01
        • 1970-01-01
        • 2015-09-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-28
        相关资源
        最近更新 更多