ImportError:无法在flask_oauthlib中导入名称“ bytes_type”

时间:2019-02-10 03:45:34

标签: python-3.x heroku flask flask-oauthlib

我尝试使用flask_oauthlib构建应用并将其部署到heroku,但出现一些错误

2019-02-10T03:14:55.112096+00:00 app[web.1]:   File "/app/flask_oauthlib/client.py", line 20, in <module>
2019-02-10T03:14:55.112098+00:00 app[web.1]:     from .utils import to_bytes
2019-02-10T03:14:55.112099+00:00 app[web.1]:   File "/app/flask_oauthlib/utils.py", line 5, in <module>
2019-02-10T03:14:55.112102+00:00 app[web.1]:     from oauthlib.common import to_unicode, bytes_type
2019-02-10T03:14:55.112106+00:00 app[web.1]: ImportError: cannot import name 'bytes_type'
2019-02-10T03:14:55.112616+00:00 app[web.1]: [2019-02-10 03:14:55 +0000] [11] [INFO] Worker exiting (pid: 11)
2019-02-10T03:14:55.112784+00:00 app[web.1]: [2019-02-10 03:14:55 +0000] [10] [INFO] Worker exiting (pid: 10)
2019-02-10T03:14:55.267604+00:00 app[web.1]: [2019-02-10 03:14:55 +0000] [4] [INFO] Shutting down: Master
2019-02-10T03:14:55.267763+00:00 app[web.1]: [2019-02-10 03:14:55 +0000] [4] [INFO] Reason: Worker failed to boot.
2019-02-10T03:17:31.597353+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=askfess.herokuapp.com request_id=1e14f0da-5bbe-4849-9308-3ecf8a49306f fwd="140.213.38.39" dyno= connect= service= status=503 bytes= protocol=https

有什么想法可以解决吗?仅当我尝试在heroku中进行部署但在localhost中可以正常工作时,应用程序错误

2 个答案:

答案 0 :(得分:0)

运行pip安装请求-oauthlib:

pip install requests-oauthlib==1.1.0 

为我解决了这个问题!

答案 1 :(得分:0)

尝试在python 3.7上运行项目时出现此错误。 Flask oauthlib不支持python 3.7 我切换到python 3.5,它工作正常。