Python Tweepy安装?

Python Tweepy安装?,python,python-2.7,tweepy,Python,Python 2.7,Tweepy,我尝试使用不同的方法安装tweepy,例如 pip安装tweepy sudo-pip-install-tweepy 最后,我从github下载了zip包,并使用命令安装: python setup.py install 显然,安装已成功完成,但是,当我运行一个只包含一行的简单程序(如import tweepy)时,会引发以下错误: 回溯(最近一次呼叫最后一次): 文件“tweepytest.py”,第1行,在 进口粗花呢 文件“build/bdist.macosx-10.6-intel/e

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

  • pip安装tweepy
  • sudo-pip-install-tweepy
最后,我从github下载了zip包,并使用命令安装:

python setup.py install
显然,安装已成功完成,但是,当我运行一个只包含一行的简单程序(如
import tweepy
)时,会引发以下错误:

回溯(最近一次呼叫最后一次):
文件“tweepytest.py”,第1行,在
进口粗花呢
文件“build/bdist.macosx-10.6-intel/egg/tweepy/__init__.py”,第14行,在
文件“build/bdist.macosx-10.6-intel/egg/tweepy/api.py”,第12行,在
文件“build/bdist.macosx-10.6-intel/egg/tweepy/binder.py”,第11行,在
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/requests/_init__.py”,第53行,在
从.packages.urllib3.contrib导入pyopenssl
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/requests/packages/__init___.py”,第27行,在
从…起导入urllib3
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/__-init___.py”,中的第8行
from.connectionpool导入(
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/requests/packages/urllib3/connectionpool.py”,第33行,在
from.packages.ssl\u match\u主机名导入证书错误
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/urllib3/packages/__-init___;.py”,第3行,在
从导入ssl\u匹配\u主机名
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site packages/requests/packages/urllib3/packages/ssl_match_hostname/__init__;.py”,第3行,在
从ssl导入证书错误,匹配\u主机名
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py”,第90行,在
导入文本包装
文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py”,第40行,在
类TextWrapper:
TextWrapper中的文件“/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py”,第82行
whitespace_trans=string.maketrans(_whitespace,'*len(_whitespace))
AttributeError:“模块”对象没有属性“maketrans”

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

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

您应该试试

pip3 install tweepy
或者


您可以尝试使用另一种安装选项从GitHub克隆repo:

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

你使用的是什么操作系统(Linux,*BSD,OSX?)和什么版本的python?
sudo-pip3-install-tweepy
对我来说在LMDE-Betsy上运行得很好。@FredBarclay我有OSX(10.11),我的python版本是2.7.9。还有一个问题:你没有使用
-pip-install-tweepy
-sudo-pip-install-tweepy
(带破折号)是吗?查看
python--version
的输出,检查
python setup.py install
是否使用了正确的python版本,这可能会很有启发性。@Fredbarkli我尝试过使用这两种方法,但都不起作用:(不——我是问你是否在命令前面用了破折号。你知道,像
-pip install tweepy
而不是
pip install tweepy
:)
pip3 install tweepy
pip install git+https://github.com/tweepy/tweepy.git
git clone https://github.com/tweepy/tweepy.git
cd tweepy
pip install .