Forums

Installed NewsApi but when import, ModuleNotFoundError: No module named 'newsapi'

Hi I'm using flask to deploy the news api, and I have successfully pip installed in the bash However when I run below code I got error, can someone help me what did I do wrong?

from flask import Flask, request, render_template, make_response, jsonify
from newsapi import NewsApiClient


app = Flask(__name__)
app.config["DEBUG"] = True

@app.route("/", methods=["GET", "POST"])

def adder_page():
    errors = ""......


2021-02-16 14:55:44,608: Error running WSGI application
2021-02-16 14:55:44,608: ModuleNotFoundError: No module named 'newsapi'
2021-02-16 14:55:44,608:   File "/var/www/qqyutaka_pythonanywhere_com_wsgi.py", line 16, in <module>
2021-02-16 14:55:44,608:     from flask_app import app as application  # noqa
2021-02-16 14:55:44,608: 
2021-02-16 14:55:44,609:   File "/home/qqyutaka/mysite/flask_app.py", line 8, in <module>
2021-02-16 14:55:44,609:     from newsapi import NewsApiClient
2021-02-16 14:55:44,609: ***************************************************
2021-02-16 14:55:44,609: If you're seeing an import error and don't know why,
2021-02-16 14:55:44,609: we have a dedicated help page to help you debug: 
2021-02-16 14:55:44,609: https://help.pythonanywhere.com/pages/DebuggingImportError/
2021-02-16 14:55:44,609: ***************************************************

[edit by admin: formatting]

Are you sure you installed it for the same version of Python as the one you are using to run your code? Each version of Python has its own set of installed packages; see this help page for the details.

newsapi seems to work only till python 3.7. I recently upgraded to python 3.8 and got error 'cannot import name 'NewsApiClient' from 'newsapi' . I came here looking to see if anyone had figured out how to use newapi with python 3.8.

According to the PyPI page of the project, it supports Python versions up to Python 3.7, it looks like the package hasn't been maintained since Dec 2019.