Can't import NewsApiClient from newsapi during deployment

I got the feedback below while trying to deploy my app. Anyone with some assistance?

ImportError: cannot import name 'NewsApiClient' from 'newsapi' (/home/adminuser/venv/lib/python3.9/site-packages/newsapi/__init__.py)
2024-02-28 08:46:02.355 503 GET /script-health-check (10.12.123.4) 48.26ms

here’s the github repo

Do you expect 'NewsApiClient' to be defined in 'newsapi'? Why is that?

But the script runs just perfectly on PC, can’t figure out why it fails on cloud.

Maybe because you have a different newsapi installed.

should I include my newsapi version on the requirements file?

Yes, I guess.

I’m now getting the error code below:


Collecting bs4

  Downloading bs4-0.0.2-py2.py3-none-any.whl (1.2 kB)

ERROR: Could not find a version that satisfies the requirement newsapi==0.2.7 (from versions: 0.1.0, 0.1.1)

ERROR: No matching distribution found for newsapi==0.2.7

WARNING: You are using pip version 22.0.3; however, version 24.0 is available.

You should consider upgrading via the '/home/adminuser/venv/bin/python -m pip install --upgrade pip' command.

Checking if Streamlit is installed

figured it, it’s newsapi-python not news api

1 Like

I however ran into another problem, the app is deployed but my api keys are not defined, i pasted them on the secrets under advanced settings

Indeed, news_api_key is undefined. Putting stuff in secrets is not going to magically define it.

got it thank you