为什么可以';我不能从Python发送tweet吗?

为什么可以';我不能从Python发送tweet吗?,python,api,twitter,Python,Api,Twitter,我已经做了上面说的所有事情,但是当我把它填满并按下回车键时,什么也没发生。你能帮我吗 好的,正是因为这个原因,我无法正确下载python twitter API。当我尝试按照以下步骤操作时,会出现此错误: import twitter api = twitter.Api(consumer_key=' ', consumer_secret=' ', access_token_key=' ',

我已经做了上面说的所有事情,但是当我把它填满并按下回车键时,什么也没发生。你能帮我吗

好的,正是因为这个原因,我无法正确下载python twitter API。当我尝试按照以下步骤操作时,会出现此错误:

import twitter

api = twitter.Api(consumer_key=' ',
                       consumer_secret=' ',
                        access_token_key=' ',
                        access_token_secret=' ')

friends=api.PostUpdate("First Tweet from PYTHON APP ")

好的,我安装了
setup.py
,但现在它出现以下错误:

figen@figen-Satellite-A350:~/Downloads/python-twitter-0.8.2$ python setup.py install
running install
running build
running build_py
running install_lib
copying build/lib.linux-x86_64-2.7/twitter.py -> /usr/local/lib/python2.7/dist-packages
error: /usr/local/lib/python2.7/dist-packages/twitter.py: Permission denied
figen@figen-Satellite-A350:~/Downloads/python-twitter-0.8.2$python twitter\u test.py
回溯(最近一次呼叫最后一次):
文件“twitter_test.py”,第29行,在
导入推特
文件“/home/figen/Downloads/python-twitter-0.8.2/twitter.py”,第65行,在
将oauth2导入为oauth
ImportError:没有名为oauth2的模块
现在它说twitter模块没有这个模块。如何得到它

figen@figen-Satellite-A350:~/Downloads/python-twitter-0.8.2$ python twitter_test.py
Traceback (most recent call last):
  File "twitter_test.py", line 29, in <module>
    import twitter
  File "/home/figen/Downloads/python-twitter-0.8.2/twitter.py", line 65, in <module>
    import oauth2 as oauth
ImportError: No module named oauth2
api=twitter.api(consumer_key='removed',
消费者(已删除),,
访问令牌密钥=“已删除”,
访问\u令牌\u secret='removed')
friends=api.PostUpdate(“如果您看到了这一点,我设法从Python Shell.Yay!=)发送了我的第一条推文”)
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
api=twitter.api(consumer_key='removed for security=)',
AttributeError:“模块”对象没有属性“Api”

有几种因素会导致您的问题


1) 权限被拒绝错误(错误:/usr/local/lib/python2.7/dist-packages/twitter.py:permission denied)是因为您没有管理员权限。尝试
sudo python setup.py安装

2) 您需要安装缺少的依赖项(即oauth2)。您可以从这里获得oauth2。请确保您具有所需的其他依赖项,即SimpleJson和HTTPLib2。您可以在上找到有关此信息的更多详细信息


希望这能解决它

有几件事导致了你的问题


1) 权限被拒绝错误(错误:/usr/local/lib/python2.7/dist-packages/twitter.py:permission denied)是因为您没有管理员权限。尝试
sudo python setup.py安装

2) 您需要安装缺少的依赖项(即oauth2)。您可以从这里获得oauth2。请确保您具有所需的其他依赖项,即SimpleJson和HTTPLib2。您可以在上找到有关此信息的更多详细信息


希望这能解决它

您需要安装包含Api的twitter。此版本包含Api。

您需要安装包含Api的twitter。此版本包含Api。

好的,这可能是一个愚蠢的问题,但这不是您试图运行的实际代码?你试的时候把钥匙填好了吗?是的,我填好了。我更新了问题。请再看一遍,好吗?试试
sudo python setup.py install
Thx-Peter,它工作了,但现在又出现了一个错误。你能再看一下更新的问题吗?@FigenGungor:“没有名为oauth2的模块”是一条简单的错误消息:你需要安装oauth2模块。好的,这可能是一个愚蠢的问题,但这不是你试图运行的实际代码?你试的时候把钥匙填好了吗?是的,我填好了。我更新了问题。请再看一遍,好吗?试试
sudo python setup.py install
Thx-Peter,它工作了,但现在又出现了一个错误。您能再看一次更新的问题吗?@FigenGungor:“没有名为oauth2的模块”是一条简单的错误消息:您需要安装oauth2模块。这不是答案。OP已在使用建议的包版本。另外,问题已经由先前的答案解决。这是一个非答案。OP已在使用建议的包版本。同样,这个问题已经由先前的答案解决了。
  api = twitter.Api(consumer_key='removed',
                       consumer_secret='removed',
                        access_token_key='removed',
                        access_token_secret='removed')

  friends=api.PostUpdate("If you see this,I managed to send my first tweet from Python    Shell. Yay! =)")
  Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
  api = twitter.Api(consumer_key='removed for security=)',
  AttributeError: 'module' object has no attribute 'Api'