问题
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")
回答1:
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.
来源:https://stackoverflow.com/questions/61669769/requests-works-locally-but-not-deployed-on-heroku