Python中tweepy的怪异行为?
我在OSX(10.11)上安装了python 2.7.9。我已经安装了tweepy 3.5.0和simplejson 3.8.1。当我编写一个程序(IDE:textWrangler)来更新twitter帐户的状态(通过使用tweepy)并使用命令行运行该程序时,它会在程序中的“import tweepy”上抛出错误。然而,当我在PythonShell上运行相同的代码时,它成功地执行了(没有任何错误)。有什么建议或意见吗Python中tweepy的怪异行为?,python,python-2.7,Python,Python 2.7,我在OSX(10.11)上安装了python 2.7.9。我已经安装了tweepy 3.5.0和simplejson 3.8.1。当我编写一个程序(IDE:textWrangler)来更新twitter帐户的状态(通过使用tweepy)并使用命令行运行该程序时,它会在程序中的“import tweepy”上抛出错误。然而,当我在PythonShell上运行相同的代码时,它成功地执行了(没有任何错误)。有什么建议或意见吗 Traceback (most recent call last): F
Traceback (most recent call last):
File "tweepytesting.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'
就在import tweepy
上方,然后打印以下内容:
<module 'string' from '/Users/yasirmuhammad/Desktop/learnpython/string.pyc'>
发生了什么错误?你的密码在哪里@错误在程序的第一行。程序的第一行是“import tweepy”,错误是“Traceback(最后一次调用):文件“tweepytesting.py”,第1行,在import tweepy中”请编辑您的问题并包括完整的回溯(您遗漏了最重要的部分)您是否有一个名为string.py
的文件?如果print(string)
仍然打印该行,这意味着该文件仍然存在。Python无法“发明”文件:)
<module 'string' from '/Users/yasirmuhammad/Desktop/learnpython/string.pyc'>