Forums

Pyttsx3 import error

Hello, I am struggling with import pyttsx3 (also had problems with other import modules). I did the standard command "pip install pyttsx3" and made sure the version aligned with Python 3.9.13.

I checked the bash again and it does indeed say that it has been downloaded. Great. When I imported it onto the Flask server, it failed and I got the following error:

 2023-08-02 18:30:42,002: Error running WSGI application 2023-08-02
 18:30:42,007: ModuleNotFoundError: No module named 'pyttsx3'
 2023-08-02 18:30:42,008:   File
 "/var/www/lyraassistant_eu_pythonanywhere_com_wsgi.py", line 16, in
 <module> 2023-08-02 18:30:42,008:     from flask_app import app as
 application  # noqa 2023-08-02 18:30:42,008:  2023-08-02 18:30:42,008:
 File "/home/LyraAssistant/mysite/flask_app.py", line 6, in <module>
 2023-08-02 18:30:42,008:     import pyttsx3 2023-08-02 18:30:42,008:
 *************************************************** 2023-08-02 18:30:42,008: If you're seeing an import error and don't know why,
 2023-08-02 18:30:42,008: we have a dedicated help page to help you
 debug:  2023-08-02 18:30:42,009:
 https://help.pythonanywhere.com/pages/DebuggingImportError/ 2023-08-02
 18:30:42,009: ***************************************************

I went to the DebuggingImportError site, and honestly, it ended up confusing me more. I tried importing sys and did the following line:

sys.path.append("/home/LyraAssistant/.local/bin/python")

Still didn't work. Pretty hard stuck, I know it is mentioning an error with WSGI but I am too inexperienced with Flask to understand it. Any help is appreciated. Thank you!

The command pip will install for the default version of Python for your account, which is not the same as the one that you've configured a particular website to use. So to install for Python 3.9, you should use 'pip3.9' instead.

I am actually feeling like a muffin right now. Thanks for your response, much appreciated my guy. Hope you have a great day!

No problem at all, glad to help!