1

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()
Daniel dos Santos
  • 241
  • 4
  • 10
  • 25
  • 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. –  Jan 17 '19 at 20:35
  • It returns "Requirement already satisfied: pyttsx3 in..." in terminal but my code in pyCharm still returns "ModuleNotFoundError: No module named 'Foundation'" – Daniel dos Santos Jan 18 '19 at 10:45
  • 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). –  Jan 18 '19 at 17:32

10 Answers10

5
  1. Go to your terminal and type pip uninstall pyttsx3

  2. Type pip install pyttsx3==2.71

  3. Then your problem is solved

pzaenger
  • 11,381
  • 3
  • 45
  • 46
Rajendro Sau
  • 61
  • 1
  • 5
1

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.

Nitesh
  • 138
  • 1
  • 7
1

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.

0

If your still receiving ModuleNotFoundError after a uninstall and re-install of pyttsx3 then this maybe be the solution for you. In your terminal start by uninstalling pyttsx3

pip uninstall pyttsx3

Then Install pipenv like so

pip install -u pipenv

then

pipenv install pyttsx3

You can find more about pipenv if you like from here.

Here is a stackoverflow answer that proves it works with your problem.

0

For python versions from and above 2.7:

  • File>Settings>Project>project interpreter>use the + sign to add package.
  • Search for pyttsx3.
  • click on versions.
  • change the Version to 2.7
  • install the package.

It took me hours to figure it out, but it works.

Try any possible code on the text-to-speech.

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
0

if you are running visual code, then run the file from python terminal when right click on code window option present there

  • 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”. – tzot Oct 23 '20 at 12:46
0

In my case this problem occurred when I updated my python version. So I simply uninstalled the older version of python and added the new version on path by the following process:

This PC -> Properties -> Advanced System settings -> Environment Variable -> System Variables -> Path -> Edit -> Browse -> Select the Python folder where it is installed.

After that in the terminal update you pip version by the command:

'path' python -m pip install –upgrade pip

In place of path write the file location.

Now simply install pyttsx3 by the command:

pip install pyttsx3

Now your module is ready to be used. To check run a simple program:

import pyttsx3
speaker = pyttsx3.init()
speaker.say('hello there')
speaker.runAndWait()
ALEX
  • 1
0

Try installing with this command:

py -3 -m pip install pyttsx3
shreyasm-dev
  • 2,711
  • 5
  • 16
  • 34
0

You can use pyttsx3 by uninstalling the older one and installing the new one or you can go with pywin32 with this command pip install pywin32

Anurag
  • 1
  • 1
0

[Work on Mac]

Pycharm --> Preference --> Project --> Python Interpreter --> click on a "+" symbol (down left corner) --> search "pyttsx3" (or any pip package) --> Install (It will take awhile but works)

enter image description here