0

I have a RPi 4B running RaspberryPi OS buster and I want to be able to speak out the news using ./speech. I have been following a tutorial and I got everything up and running but I am having some error popping up, again and again, tried everything I could but no luck.

Traceback (most recent call last):
  File "get_news.py", line 4, in <module>
    import feedparser
ModuleNotFoundError: No module named 'feedparser'

I thought it might be due to virtual environment not being there, after doing so, I am still facing the same and even more errors

Traceback (most recent call last):
  File "get_news.py", line 4, in <module>
    import feedparser
  File "/usr/local/lib/python2.7/dist-packages/feedparser/__init__.py", line 31, in <module>
    from .api import parse
  File "/usr/local/lib/python2.7/dist-packages/feedparser/api.py", line 56, in <module>
    from . import http
  File "/usr/local/lib/python2.7/dist-packages/feedparser/http.py", line 156
    new_pieces[1] = f'{url_pieces.hostname}:{url_pieces.port}'
                                                             ^
SyntaxError: invalid syntax

Can anyone help me fix this...my idea is I want the RPi to speak out the news headlines by reading it off BBC India or India Today.

4
  • What command are you using to run your scripts? Try python3 instead of python... Dec 22 '20 at 12:12
  • Tried, No luck. Dec 22 '20 at 12:40
  • Did you accidentally use pip instead of pip3 while installing the modules? And don't use sudo with pip3. Dec 22 '20 at 12:46
  • And also, please use backticks (`) to format your code. Put 3 backticks (```) before the start and end of your code. Dec 22 '20 at 12:49
0

So here's how I found the solution. I had a speech.sh which was an executable script in another folder, so the permission to run it was local to that folder which I wasn't aware of. So I copied it to the local read_news folder and ran sudo chmod 755 {script name } and deactivated my venv and ran pip3 install feedparser and that did it for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.