How to fix 'pyttsx3' when it isn't working?

21,202

Solution 1

  1. Go to your terminal and type pip uninstall pyttsx3

  2. Type pip install pyttsx3==2.71

  3. Then your problem is solved

Solution 2

At first try to install it by writing this commandpy -3 -m pip install pyttsx3 in terminal. Again, if it get installed but shows error, then go to terminal and type sudo apt install libespeak1 (in ubuntu) Hope your issue will be solved.

Solution 3

If "Requirement already satisfied: pyttsx3 in..." in terminal and module is not found in pycharm then you should install pyttsx3 package in your pycharm. Either create a virtual environment and install the package through pip Or go to pycharm -> setting -> project interpreter, here you'll find the list of packages that has been installed in your pycharm. You can add more packages as per your requirements.

For me it worked.

Share:
21,202
Daniel dos Santos
Author by

Daniel dos Santos

Updated on July 09, 2022

Comments

  • Daniel dos Santos
    Daniel dos Santos almost 2 years

    When I run the code in pyCharm it returns, "ModuleNotFoundError: No module named 'Foundation'".

    I tried to install pyttsx3 in my terminal it returns "Could not install packages due to an EnvironmentError:" I then tried to install pyobjc but got the same error. Lastly I tried to install and import Foundation but it did nothing.

    import pyttsx3
    
    engine = pyttsx3.init()
    engine.say("Testing")
    engine.runAndWait()
    
    • Admin
      Admin over 5 years
      How did you perform the install of pyttxs3? Did you "pip3 install pyttsx3 ?" I just did this and re-ran your code and did not see the error.
    • Daniel dos Santos
      Daniel dos Santos over 5 years
      It returns "Requirement already satisfied: pyttsx3 in..." in terminal but my code in pyCharm still returns "ModuleNotFoundError: No module named 'Foundation'"
    • Admin
      Admin over 5 years
      You need to first determine if this is really pyCharm related. Create a new foo.py module. First, import pkgutil. Then add the following line of code. print(1 if pkgutil.find_loader("pyttsx3") else 0). Run this script on the command line like: py foo.py You should see either 0 or 1 on the output. '1' is if the module was successfully installed(maybe related to pyCharm), '0' is the module is not installed in the python library(would require you to possibly uninstall and re-install pyttsx3 but not pyCharm related).
  • homelessmathaddict
    homelessmathaddict almost 4 years
    pyttsx3 2.90 wasn't working but this fixed it (July 2020)
  • Ishbir
    Ishbir over 3 years
    Please make sure your answer is relevant to the question; the OP states they run PyCharm, so this lowers the probability of your answer being helpful when it begins with “if you are running visual code”.