2016-04-01 9 views
2

これまでにoauth2を使ってredditのサーバに接続できましたが、今はスクリプトを実行しているときにKeyErrorに続いてNoSectionErrorと表示されます。コードの下には例外が続きます(コードは必需品に縮小されています)。変数に '' praw.Reddit ''を割り当てるときのKeyError

import praw 


# Configuration 
APP_UA = 'useragent' 
... 
... 
... 

r = praw.Reddit(APP_UA) 

エラーメッセージ:

Traceback (most recent call last): 
    File "D:\Directory\Python\lib\configparser.py", line 843, in items 
    d.update(self._sections[section]) 
KeyError: 'useragent' 

A NoSectionError occurred when handling the above exception. 
"During handling of the above exception, another exception occurred:" 

'Traceback (most recent call last): 
    File "D:\Directory\Python\Projects\myprj for Reddit, globaloffensive\oddshotcrawler.py", line 19, in <module> 
    r = praw.Reddit(APP_UA) 
    File "D:\Directory\Python\lib\site-packages\praw\reddit.py", line 84, in __init__ 
    **config_settings) 
    File "D:\Directory\Python\lib\site-packages\praw\config.py", line 47, in __init__ 
    raw = dict(Config.CONFIG.items(site_name), **settings) 
    File "D:\Directory\Python\lib\configparser.py", line 846, in items 
    raise NoSectionError(section) 
configparser.NoSectionError: No section: 'useragent' 
[Finished in 0.2s] 

答えて

3

はそれをのuser_agentのkwargを与えてみてください。

r = praw.Reddit(useragent=APP_UA) 
+0

が働いたが、新たなトレースバックエラーました: 'トレースバック(最後の最新の呼び出し): ファイルを "D:Redditのための\ディレクトリ\ Pythonの\プロジェクト\ Oddshotcrawler、globaloffensive \ oddshotcrawler.py"、ライン19、 (ファイルのD:¥Directory¥Python¥lib¥site-packages¥praw¥reddit.py)、92行目、__init__内 r = praw.Reddit(useragent = APP_UA) ファイル「D:¥Directory¥Python¥lib¥site-packages¥praw¥reddit.py」行92、__init__ raise ClientException )) praw.exceptions.ClientException:必須のコンフィグレーション設定 'client_id'がありません。 この設定はpraw.iniファイル、 'Reddit'クラスコンストラクタのキーワード引数、または環境変数として提供できます。 –

+0

あなたのボットが許可される必要があるように見えますが、ここで読むことができますhttp: //praw.readthedocs.org/en/stable/pages/oauth.html – John

+0

APP_UAとは何ですか?私は完全な作業の例を見つけようとしていますが、できませんでした。私は何をprawに渡すべきか分からない.Reddit –

関連する問題