Python 错误:";只有unicode对象是可转义的。没有得到任何类型的<;类别';非类型'&燃气轮机&引用;。有人能帮我找出代码中的错误吗?

Python 错误:";只有unicode对象是可转义的。没有得到任何类型的<;类别';非类型'&燃气轮机&引用;。有人能帮我找出代码中的错误吗?,python,bots,tweepy,python-unicode,twitterapi-python,Python,Bots,Tweepy,Python Unicode,Twitterapi Python,一般来说,我是Twitter开发和Python编程的初学者,但最近我一直在尝试构建一个机器人,当在回复推文时添加标签时,它会找到关键字,并使用Google从可靠来源提供一些关于原始推文主题的信息。然而,我在编程时遇到了一个主要问题:API无法创建,因为代码触发了错误“只有unicode对象是可转义的”。我已经使用module Config将我的twitterapi凭证设置为环境变量,这似乎本身就可以很好地工作。在尝试运行bot之前,我激活了我的虚拟环境并导出了env变量,因此我不认为这个问题与错

一般来说,我是Twitter开发和Python编程的初学者,但最近我一直在尝试构建一个机器人,当在回复推文时添加标签时,它会找到关键字,并使用Google从可靠来源提供一些关于原始推文主题的信息。然而,我在编程时遇到了一个主要问题:
API
无法创建,因为代码触发了错误“只有unicode对象是可转义的”。我已经使用module Config将我的twitterapi凭证设置为环境变量,这似乎本身就可以很好地工作。在尝试运行bot之前,我激活了我的虚拟环境并导出了env变量,因此我不认为这个问题与错误设置这些变量有关,但我也不确定这一点! 代码是这样的:

import tweepy
import logging
from config import create_api
import time
import re
from googlesearch import search
import sys
import io

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()

api = tweepy.API

def check_mentions(api, keywords, since_id):

    logger.info("Collecting info")

    new_since_id = since_id

    for tweet in tweepy.Cursor(api.mentions_timeline,
        since_id=since_id).items():

        new_since_id = max(tweet.id, new_since_id)


        if tweet.in_reply_to_status_id is not None:
            in_reply_to_status_id = previous_tweet.id
            status_id = tweet.in_reply_to_status_id
            tweet_u = api.get_status(status_id,tweet_mode='extended')
            #to store the output -links- as a variable to use it later
            old_stdout = sys.stdout
            new_stdout = io.StringIO()
            sys.stdout = new_stdout


            output = new_stdout.getvalue()
            sys.stdout = old_stdout

        print(output)


        text = output

        # remove words that are between 1 and 3 characters long
        shortword = re.compile(r'\W*\b\w{1,3}\b')

        print(shortword.sub('', text))

        

        keywords_search = print(shortword.sub('', text))

        if keywords_search is not None:

                mystring = search(keywords_search, num_results=500)
        else:
                mystring = search("error", num_results=1)



        for word in mystring:
                if "harvard" in word or "cornell" in word or "researchgate" in word or "yale" in word or "rutgers" in word or "caltech" in word or "upenn" in word or "princeton" in word or "columbia" in word or "journal" in word or "mit" in word or "stanford" in word or "gov" in word or "pubmed" in word:
                                print(word)

        #to store the output -links- as a variable to use it later
        old_stdout = sys.stdout
        new_stdout = io.StringIO()
        sys.stdout = new_stdout

        for word in mystring:
                if "harvard" in word or "cornell" in word or "researchgate" in word or "yale" in word or "rutgers" in word or "caltech" in word or "upenn" in word or "princeton" in word or "columbia" in word or "journal" in word or "mit" in word or "stanford" in word or "gov" in word or "pubmed" in word:
                                print(word)

        #to print normally again
        output = new_stdout.getvalue()

        sys.stdout = old_stdout
        print(output)


        if output is not None:
                status = "Hi there! This may be what you're looking for" and print(output),
                len(status) <= 280
                api.update_status(status, in_reply_to_status_id=tweet.id, auto_populate_reply_metadata=False),

        else:
                status = "Sorry, I cannot help you with that :(. You might want to try again with a distinctly sourced Tweet",
                len(status) <= 280
                api.update_status(status, in_reply_to_status_id=tweet.id, auto_populate_reply_metadata=False),

        return new_since_id





def main():
    api = create_api()
    since_id = 1 #the last mention you have.
    while True:
        print(since_id)
        since_id = check_mentions(api, ["help", "support"], since_id)
        logger.info("Waiting...")
        time.sleep(15)

if __name__ == "__main__":
    main()

错误是:

ERROR:root:Error creating API
Traceback (most recent call last):
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 184, in execute
    resp = self.session.request(self.method,
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 449, in prepare_request
    p.prepare(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 318, in prepare
    self.prepare_auth(auth, url)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 549, in prepare_auth
    r = auth(self)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests_oauthlib\oauth1_auth.py", line 108, in __call__
    r.url, headers, _ = self.client.sign(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 127, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 209, in _render
    headers = parameters.prepare_headers(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\parameters.py", line 59, in prepare_headers
    escaped_value = utils.escape(value)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable. ' +
ValueError: Only unicode objects are escapable. Got None of type <class 'NoneType'>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\config.py", line 23, in create_api
    api.verify_credentials()
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\api.py", line 672, in verify_credentials
    return bind_api(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 253, in _call
    return method.execute()
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 192, in execute
    six.reraise(TweepError, TweepError('Failed to send request: %s' % e), sys.exc_info()[2])
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 184, in execute
    resp = self.session.request(self.method,
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 449, in prepare_request
    p.prepare(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 318, in prepare
    self.prepare_auth(auth, url)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 549, in prepare_auth
    r = auth(self)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests_oauthlib\oauth1_auth.py", line 108, in __call__
    r.url, headers, _ = self.client.sign(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 127, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 209, in _render
    headers = parameters.prepare_headers(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\parameters.py", line 59, in prepare_headers
    escaped_value = utils.escape(value)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable. ' +
tweepy.error.TweepError: Failed to send request: Only unicode objects are escapable. Got None of type <class 'NoneType'>.
Traceback (most recent call last):
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 184, in execute
    resp = self.session.request(self.method,
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 449, in prepare_request
    p.prepare(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 318, in prepare
    self.prepare_auth(auth, url)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 549, in prepare_auth
    r = auth(self)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests_oauthlib\oauth1_auth.py", line 108, in __call__
    r.url, headers, _ = self.client.sign(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 127, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 209, in _render
    headers = parameters.prepare_headers(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\parameters.py", line 59, in prepare_headers
    escaped_value = utils.escape(value)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable. ' +
ValueError: Only unicode objects are escapable. Got None of type <class 'NoneType'>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\botstring20.py", line 114, in <module>
    main()
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\botstring20.py", line 105, in main
    api = create_api()
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\config.py", line 26, in create_api
    raise e
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\config.py", line 23, in create_api
    api.verify_credentials()
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\api.py", line 672, in verify_credentials
    return bind_api(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 253, in _call
    return method.execute()
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 192, in execute
    six.reraise(TweepError, TweepError('Failed to send request: %s' % e), sys.exc_info()[2])
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 184, in execute
    resp = self.session.request(self.method,
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 449, in prepare_request
    p.prepare(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 318, in prepare
    self.prepare_auth(auth, url)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 549, in prepare_auth
    r = auth(self)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests_oauthlib\oauth1_auth.py", line 108, in __call__
    r.url, headers, _ = self.client.sign(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 127, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 209, in _render
    headers = parameters.prepare_headers(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\parameters.py", line 59, in prepare_headers
    escaped_value = utils.escape(value)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable. ' +
tweepy.error.TweepError: Failed to send request: Only unicode objects are escapable. Got None of type <class 'NoneType'>.


ERROR:root:创建API时出错
回溯(最近一次呼叫最后一次):
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\localpackages\Python39\site Packages\tweepy\binder.py”,执行中第184行
resp=self.session.request(self.method,
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\requests\sessions.py”,请求中的第516行
准备=自我准备请求(req)
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\localpackages\Python39\site Packages\requests\sessions.py”,第449行,在prepare\u请求中
p、 预备(
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\requests\models.py”,第318行,在prepare中
self.prepare\u auth(auth,url)
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\requests\models.py”,第549行,在prepare\u auth
r=auth(self)
调用中第108行的文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\requests\u oauthlib\oauth1_auth.py”__
r、 url,标题,=self.client.sign(
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\oauthlib\oauth1\rfc5849\\ uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
('oauth_签名',self.get_oauth_签名(请求)))
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\oauthlib\oauth1\rfc5849\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu init.py”,第127行,在get\uuuuuuuu
uri,头,body=self.\u呈现(请求)
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\oauthlib\oauth1\rfc5849\\ uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
标题=参数。准备标题(
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\oauthlib\oauth1\rfc5849\utils.py”,第32行,在包装器中
返回目标(参数、*args、**kwargs)
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\oauthlib\oauth1\rfc5849\parameters.py”,第59行,在prepare\u标题中
转义值=utils.escape(值)
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\oauthlib\oauth1\rfc5849\utils.py”,在escape中的第56行
raise VALUERROR('只有unicode对象是可转义的。'+
ValueError:只有unicode对象是可转义的。未获取任何类型的。
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\config.py”,第23行,在create\U api中
api.verify_凭证()
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\localpackages\Python39\site Packages\tweepy\api.py”,第672行,位于verify\u凭证中
返回绑定api(
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\localpackages\Python39\site Packages\tweepy\binder.py”,第253行,在调用中
返回方法execute()
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\tweepy\binder.py”,执行中第192行
6.重新发送(TweepError,TweepError('发送请求失败:%s'%e],sys.exc_info()[2])
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\six.py”,第702行,重新登录
通过_回溯(tb)提升值
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\localpackages\Python39\site Packages\tweepy\binder.py”,执行中第184行
resp=self.session.request(self.method,
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\Local Packages\Python39\site Packages\requests\sessions.py”,请求中的第516行
准备=自我准备请求(req)
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\localpackages\Python39\site Packages\requests\sessions.py”,第449行,在prepare\u请求中
p、 预备(
文件“C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9\u qbz5n2kfra8p0\LocalCache\localpackages\Python39\site Packages\requee
ERROR:root:Error creating API
Traceback (most recent call last):
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 184, in execute
    resp = self.session.request(self.method,
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 449, in prepare_request
    p.prepare(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 318, in prepare
    self.prepare_auth(auth, url)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 549, in prepare_auth
    r = auth(self)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests_oauthlib\oauth1_auth.py", line 108, in __call__
    r.url, headers, _ = self.client.sign(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 127, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 209, in _render
    headers = parameters.prepare_headers(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\parameters.py", line 59, in prepare_headers
    escaped_value = utils.escape(value)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable. ' +
ValueError: Only unicode objects are escapable. Got None of type <class 'NoneType'>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\config.py", line 23, in create_api
    api.verify_credentials()
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\api.py", line 672, in verify_credentials
    return bind_api(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 253, in _call
    return method.execute()
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 192, in execute
    six.reraise(TweepError, TweepError('Failed to send request: %s' % e), sys.exc_info()[2])
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 184, in execute
    resp = self.session.request(self.method,
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 449, in prepare_request
    p.prepare(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 318, in prepare
    self.prepare_auth(auth, url)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 549, in prepare_auth
    r = auth(self)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests_oauthlib\oauth1_auth.py", line 108, in __call__
    r.url, headers, _ = self.client.sign(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 127, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 209, in _render
    headers = parameters.prepare_headers(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\parameters.py", line 59, in prepare_headers
    escaped_value = utils.escape(value)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable. ' +
tweepy.error.TweepError: Failed to send request: Only unicode objects are escapable. Got None of type <class 'NoneType'>.
Traceback (most recent call last):
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 184, in execute
    resp = self.session.request(self.method,
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 449, in prepare_request
    p.prepare(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 318, in prepare
    self.prepare_auth(auth, url)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 549, in prepare_auth
    r = auth(self)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests_oauthlib\oauth1_auth.py", line 108, in __call__
    r.url, headers, _ = self.client.sign(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 127, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 209, in _render
    headers = parameters.prepare_headers(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\parameters.py", line 59, in prepare_headers
    escaped_value = utils.escape(value)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable. ' +
ValueError: Only unicode objects are escapable. Got None of type <class 'NoneType'>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\botstring20.py", line 114, in <module>
    main()
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\botstring20.py", line 105, in main
    api = create_api()
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\config.py", line 26, in create_api
    raise e
  File "C:\Users\maria\OneDrive\Documentos\Lara\Python\Factualbot\config.py", line 23, in create_api
    api.verify_credentials()
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\api.py", line 672, in verify_credentials
    return bind_api(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 253, in _call
    return method.execute()
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 192, in execute
    six.reraise(TweepError, TweepError('Failed to send request: %s' % e), sys.exc_info()[2])
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tweepy\binder.py", line 184, in execute
    resp = self.session.request(self.method,
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 516, in request
    prep = self.prepare_request(req)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 449, in prepare_request
    p.prepare(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 318, in prepare
    self.prepare_auth(auth, url)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 549, in prepare_auth
    r = auth(self)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests_oauthlib\oauth1_auth.py", line 108, in __call__
    r.url, headers, _ = self.client.sign(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 313, in sign
    ('oauth_signature', self.get_oauth_signature(request)))
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 127, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\__init__.py", line 209, in _render
    headers = parameters.prepare_headers(
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\parameters.py", line 59, in prepare_headers
    escaped_value = utils.escape(value)
  File "C:\Users\maria\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\oauthlib\oauth1\rfc5849\utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable. ' +
tweepy.error.TweepError: Failed to send request: Only unicode objects are escapable. Got None of type <class 'NoneType'>.