请求在本地工作但未部署在 Heroku 上 [英] Requests works locally but not deployed on Heroku

查看:28
本文介绍了请求在本地工作但未部署在 Heroku 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码在本地工作,但是当我将其部署到 Heroku 时,我收到 ModuleNotFoundError: No module named 'requests'.(注意:urllib.parse 工作正常 — news_link 打印.)

This code works locally, but when I deploy it to Heroku, I get ModuleNotFoundError: No module named 'requests'. (Note: urllib.parse works fine — news_link prints.)

   import urllib.parse as url_parse
    url = rurl
    news_link = url_parse.unquote(url).split("?u=")[1].split("?fbclid")[0]
    print("here comes the news_link")
    print(news_link)
    import requests
    final_link = requests.get(news_link)
    print("here comes the final_link.url")

推荐答案

您似乎忘记在 requirements.txt 文件中包含请求,请检查它是否存在,如果存在,您可以尝试使用以下命令打开 bash 控制台此答案指示 并运行 pip freeze 以查看它是否确实已安装或不是.

It looks like you forgot to include requests in the requirements.txt file, check if it is there and in case it is you can try opening the bash console using this answer indications and run a pip freeze to see if it actually is installed or not.

这篇关于请求在本地工作但未部署在 Heroku 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆