简体   繁体   中英

Module import Error and NameError in Flask using Heroku

I do have this issue when deploying a small app to heroku, the requirements.txt is very minimal, the app crash with Cannot import module 'NewsApiClient' when using

from newsapi import NewsApiClient

and the app actually start with a 500 Internal Error when using from newsapi import *

NameError: name 'NewsApiClient' is not defined

newsapi = NewsApiClient(api_key='xxxxxxxxxx')

What I've done so far is create an empty init file on the root folder

It appears you are importing the incorrect package in your requirements.txt file. You have imported the newsapi package which is different then the python-newsapi package.

Changing the newsapi==0.1.1 to newsapi-python==0.2.3 should fix your problem with the importing error as long as you reinstall the package dependencies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM