pyttsx3 not working on freshly installed windows 10 - python

I have freshly installed windows 10 and I am trying to run the following code.
import pyttsx3;
engine = pyttsx3.init();
engine.say("I will speak this text");
engine.runAndWait() ;
This use to work on my previous windows 10 installation but now it is giving me following error
Traceback (most recent call last):
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/ayush/Desktop/sample.py", line 2, in <module>
engine = pyttsx3.init();
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\engine.py", line 52, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\driver.py", line 75, in __init__
self._module = importlib.import_module(name)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
import win32com.client
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: %1 is not a valid Win32 application.
I am using python 3.6.6 64 bit on windows 10.
I have spent many hours trying different solutions like reinstalling python, tried python versions 3.5 and 3.7, reinstalling pyttsx3, also tried solutions given in few related questions but nothing is working.
Thanks in advance

Seems like win32api.pyd (which really is DLL) is not a win32 application. So I think it's loading 64bit drivers to 32bit runtime.
In this case, I will try to uninstall 64bit python, delete it's folder and install a 32bit version. I believe this will solve your problem, since you don't really need 64bit python.
Now the problem is in win32*.pyds, so it seems like your pyttsx3 is 32bit.
According to pypi.org, you can try pip install pypiwin32 to fix both win32 and win32api errors.

I tried installing Python 32 bits but customized with all options available such as a complete library, doing this worked wonders in breaking the errors! Just lauch the .exe launcher again, hit Modify and then just install every option!

Related

I'm having an issue with PortAudio building app with py2app

enter code hereI have to update an app I made on an Intel MacBook Pro to an Apple Silicon MacBook Pro. I am having problems after build the app file with py2app. I do not know if it also has to do with MacOS Ventura. I am using python 3.9 and have installed PortAudio with Homebrew
It works perfectly if I run it directly from Terminal but if I run the app I get this lines debugging
/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/MacOS/JFSTOOLS ; exit;
myuser#MacBook-Pro-myuser ~ % /Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/MacOS/JFSTOOLS ; exit;
Traceback (most recent call last):
File "sounddevice.pyc", line 71, in <module>
OSError: PortAudio library not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/__boot__.py", line 170, in <module>
_run()
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/__boot__.py", line 84, in _run
exec(compile(source, path, "exec"), globals(), globals())
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/JFSTOOLS.py", line 27, in <module>
import sounddevice as sd
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "sounddevice.pyc", line 83, in <module>
OSError: cannot load library '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib': dlopen(/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib, 0x0002): tried: '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (errno=20), '/System/Volumes/Preboot/Cryptexes/OS/Users/jose/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (no such file), '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (errno=20)
2023-02-07 12:49:21.188 JFSTOOLS[55753:782196] Launch error
2023-02-07 12:49:21.188 JFSTOOLS[55753:782196] Launch error
See the py2app website for debugging launch issues
I have tried to update sounddevice, numpy, portaudio, etc but I am lost as I am not an expert. Any help would be appreciated

ttk bootstrap TypeError after compiling

The following error occurs after I have compiled my program and try to run the .exe:
pygame 2.1.2 (SDL 2.0.18, Python 3.10.7)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "main.py", line 35, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module
File "GUI.py", line 74, in <module>
TypeError: Style.__new__() got an unexpected keyword argument 'themes_file'
[4196] Failed to execute script 'main' due to unhandled exception!
I have tested it on 3 PCs. The results are, that as long as I run my code from VS Code, it works. It also works compiled to .exe for one friend using windows 10.
It does not work on my Windows 11 PC and also not on my second Laptop which is running Windows 10 also.
There was never any issue like that before and I can't understand whats going on

ImportError: DLL Load failed while importing LeapPython: The Specified module could not be found

Some Context: I am currently working on a project to communicate between a PyParrot Mambo drone and the Leap Motion Controller. The issue that I am having is that the Leap Motion Controller Software only works in python 2.7 and the PyParrot Mambo Drone is working in Python 3.9. I was able to find a binding for the Leap Motion Controller Software to work with Python 3.7 .When I try to run the Leap Motion code that works in Python 3.7 in Python 3.9 I get an error.
Here is the binding file used to run The Leap Motion Controller in Python 3.7. I get the following error when I run the Sample.py file from the provided folder in python 3.9:
(py39) C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7>python Sample.py
Traceback (most recent call last):
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\anaconda\envs\py39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 565, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1108, in create_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing LeapPython: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Sample.py", line 9, in <module>
import Leap, sys, time
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 17, in <module>
LeapPython = swig_import_helper()
File "C:\Users\Joginder Bassi\Downloads\LeapC-Python3.7\Leap.py", line 16, in swig_import_helper
return importlib.import_module('LeapPython')
File "C:\anaconda\envs\py39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing LeapPython: The specified module could not be found.
If someone could provide clarifications on what changes were made between python 3.7 to 3.9 that would cause these errors and a possible fix to make the python 3.7 code compatible with python 3.9. If There is a Leap Motion Software binding for newer versions of python 3 that would also be quite helpful.
The binding was generated with SWIG which does not implement the Python Stable API so you will need to rebuild the binding for each Python Version for this to work with Python 3.9.
This guide was written for Python 3.3.0 but should help to guide you on the process to rebuild this for Python 3.9.

Encounter Error after installing Pytorch using pip in python3.5

I am using windows 10 OS with Python 3.5.
I am trying to run a program related to torch. So I installed Pytorch with the help of the instructions specified on their website: Pytorch installation
See the following image for selection of the downloadable:
I installed it using :
pip install http://download.pytorch.org/whl/cpu/torch-0.4.0-cp35-cp35m-win_amd64.whl
pip install torchvision
I have encountered the following error:
Error
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\twisted\trial\runner.py", line 701, in findByName
__import__(name)
File "C:\Users\aims\Desktop\CNN\source\cnn4matrix.py", line 4, in <module>
import torch
File "C:\Python35\lib\site-packages\torch\__init__.py", line 78, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python35\lib\site-packages\twisted\trial\runner.py", line 803, in loadByName
return self.suiteFactory([self.findByName(name, recurse=recurse)])
File "C:\Python35\lib\site-packages\twisted\trial\runner.py", line 704, in findByName
return self.loadFile(_name, recurse=recurse)
File "C:\Python35\lib\site-packages\twisted\trial\runner.py", line 674, in loadFile
module = SourceFileLoader(name, fileName).load_module()
File "<frozen importlib._bootstrap_external>", line 385, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 806, in load_module
File "<frozen importlib._bootstrap_external>", line 665, in load_module
File "<frozen importlib._bootstrap>", line 268, in _load_module_shim
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\aims\Desktop\CNN\source\cnn4matrix.py", line 4, in <module>
import torch
File "C:\Python35\lib\site-packages\torch\__init__.py", line 78, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
After searching a lot I couldn't found anything related. Instead I found that I have tried: Reinstall with upgrade mode, the numpy library.
Please let me know what I can try.
EDITED:
This is the scenario for me: I have install torch from the website instructions and then opened python terminal. just written import torch and the issue is what I got. Have a look at the image: https://ibb.co/fL53HT
Please see this following thread:
https://github.com/pytorch/pytorch/issues/574
Basically, the problem might be that you have a folder called 'torch' in the same directory from where you are invoking python. So instead of the pytorch library being loaded, the folder named 'torch' is being picked up.
Do this: cd .. (to change directory), and then start python and import torch, it should work.
the one solution here if doesn't work after reinstalling Anaconda, then you can use sth. like Dependency Walker, open
[Anaconda PATH]\Lib\site-packages\torch\lib\_C.pyd
to detect what's wrong there.
and the other solution is caused by the directory torch which is generated in the same directory by compiling the source. try to simply changing the directory before open python.

Python - programs works in Linux but not in windows

I am extending a program that run without any issue in my Linux machine but not in Windows. I need to make it in Windows because the Linux machine has some issues in maintaining the Bluetooth connection.
This the error I am getting:
Traceback (most recent call last):
File "myProject.py", line 106, in <module>
application = Server(options, args)
File "myProject.py", line 42, in __init__
super(Server, self).__init__(options, args)
File "C:\Users\admin\Documents\Python\Server\lib\kernel.py", line 30, in __init__
inject.configure(self.__configure_dependencies)
File "C:\Program Files\Python35\lib\site-packages\inject.py", line 102, in configure
_INJECTOR = Injector(config)
File "C:\Program Files\Python35\lib\site-packages\inject.py", line 230, in __init__
config(binder)
File "C:\Users\admin\Documents\Python\Server\lib\kernel.py", line 58, in __configure_dependencies
module = importlib.import_module(module_source, False)
File "C:\Program Files\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 985, in _gcd_import
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
ImportError: No module named 'src\\myProject_config\\module'
I am sure the problem is with the environment not with the code that is why I did not include any.
I had an issue awhile back on one of my projects when switching from mac to windows. Turns out I just had a more recent version of the language on my windows machine that didn't like the way I did some things, I would first check the versions of your IDE as well as Language, then if they arent matching compiling your program on the linux machine and transferring the compiled version to your windows machine. If it runs fine like that, try to get matching versions of the language.

Categories

Resources