python error importing pyttsx - python

I have been trying to make a basic speech recognition system in python, using pyttx, however, when i run my code:
import speech_recognition
import pyttsx
I get this error:
Traceback (most recent call last):
File "C:\Users\brett\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyttsx__init__.py", line 37, in init
eng = _activeEngines[driverName]
File "C:\Users\brett\AppData\Local\Programs\Python\Python36-32\lib\weakref.py", line 131, in getitem
o = self.datakey
KeyError: 'sapi5'
I have tried all solutions on here so far and none of them work, if i try to run the engine driver in pyttsx, I get an error with the driver.py, saying 'main' is not a pack. if i have left out any other info, just let me know

Related

Trying use openAI gym, getting a pyglet/openGL error on running

I am trying the following code:
import gym
env = gym.make('ma_gym:Switch2-v0')
done_n = [False for _ in range(env.n_agents)]
ep_reward = 0
obs_n = env.reset()
while not all(done_n):
env.render()
obs_n, reward_n, done_n, info = env.step(env.action_space.sample())
ep_reward += sum(reward_n)
env.close()
However, when I run it, I get the following error messages:
Advay#advays-mbp evolution-org-main % /Users/Advay/miniforge3/envs/evolution_env/bin/python "/Users/Advay/Library/Mobile Documents/com~apple~CloudDocs/Brown/Research/Rose Lab/evolution-org-main/magym-room-v0/runner.py"
/Users/Advay/miniforge3/envs/evolution_env/lib/python3.9/site-packages/gym/logger.py:34: UserWarning: WARN: Box bound precision lowered by casting to float32
warnings.warn(colorize("%s: %s" % ("WARN", msg % args), "yellow"))
Traceback (most recent call last):
File "/Users/Advay/miniforge3/envs/evolution_env/lib/python3.9/site-packages/gym/envs/classic_control/rendering.py", line 27, in <module>
from pyglet.gl import *
File "/Users/Advay/miniforge3/envs/evolution_env/lib/python3.9/site-packages/pyglet/gl/__init__.py", line 95, in <module>
from pyglet.gl.lib import GLException
File "/Users/Advay/miniforge3/envs/evolution_env/lib/python3.9/site-packages/pyglet/gl/lib.py", line 147, in <module>
from pyglet.gl.lib_agl import link_GL, link_GLU, link_AGL
File "/Users/Advay/miniforge3/envs/evolution_env/lib/python3.9/site-packages/pyglet/gl/lib_agl.py", line 43, in <module>
gl_lib = pyglet.lib.load_library(framework='/System/Library/Frameworks/OpenGL.framework')
File "/Users/Advay/miniforge3/envs/evolution_env/lib/python3.9/site-packages/pyglet/lib.py", line 124, in load_library
return self.load_framework(kwargs['framework'])
File "/Users/Advay/miniforge3/envs/evolution_env/lib/python3.9/site-packages/pyglet/lib.py", line 279, in load_framework
raise ImportError("Can't find framework %s." % path)
ImportError: Can't find framework /System/Library/Frameworks/OpenGL.framework.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Advay/Library/Mobile Documents/com~apple~CloudDocs/Brown/Research/Rose Lab/evolution-org-main/magym-room-v0/runner.py", line 9, in <module>
env.render()
File "/Users/Advay/miniforge3/envs/evolution_env/lib/python3.9/site-packages/ma_gym/envs/switch/switch_one_corridor.py", line 183, in render
from gym.envs.classic_control import rendering
File "/Users/Advay/miniforge3/envs/evolution_env/lib/python3.9/site-packages/gym/envs/classic_control/rendering.py", line 29, in <module>
raise ImportError(
ImportError:
Error occurred while running `from pyglet.gl import *`
HINT: make sure you have OpenGL installed. On Ubuntu, you can run 'apt-get install python-opengl'.
If you're running on a server, you may need a virtual frame buffer; something like this should work:
'xvfb-run -s "-screen 0 1400x900x24" python <your_script.py>'
I know that the problem is somewhere in the render step but I unsure how to proceed with debugging. I am currently running the code in a conda virtual environment.
To check if the packages in question were installed correctly, I also tried:
import pyglet
import OpenGL
print("hi")
Which successfully printed "hi", confirming that the packages are installed.
Any help greatly appreciated!

AttributeError module 'select' has no attribute 'poll'

May I ask for some help? I am attempting to clone an existing GitHub project and am struggling to identify what I could be doing wrong. The project is a pluggable SXM music player written in Python ( https://github.com/AngellusMortis/sxm-player), that I've cloned and attempted to run through Visual Studio Code (v1.65.2). Upon executing the project, the code returns an error - "Exception has occurred: AttributeError module 'select' has no attribute 'poll'". Little doubt that I must be doing something incorrectly - but to this point, I haven't been able to identify what I need to do differently to get it to run properly. My sincerest apologies for needing to ask this probably simple question on this forum, but I know that this would be the place to find the experience to get this package up and running and any assistance would be greatly appreciated.
Here is the traceback for the error message:
File "C:\GitHub\sxm-player\sxm_player\utils.py", line 173, in FFmpeg
_stderr_poll: Optional[select.poll] = None
File "C:\GitHub\sxm-player\sxm_player\utils.py", line 169, in <module>
class FFmpeg:
File "C:\GitHub\sxm-player\sxm_player\runner.py", line 9, in <module>
from sxm_player.utils import configure_root_logger
File "C:\GitHub\sxm-player\sxm_player\handlers.py", line 6, in <module>
from sxm_player.runner import Runner, Worker
File "C:\GitHub\sxm-player\sxm_player\cli.py", line 23, in <module>
from sxm_player import handlers
File "C:\GitHub\sxm-player\sxm_player\__main__.py", line 3, in <module>
from sxm_player.cli import main

Python Script Fails

I am a complete novice at Python and I wish to run a script someone has made up to check against a critical windows vulnerability. I downloaded python and I thought I had downloaded all the modules and everything needed to run this script, but I keep getting an error: Please see below
C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages>zerologon.py Dc_Name IP_address ( I put this here but I edited it for confidentiality)
Traceback (most recent call last):
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\zerologon.py", line 3, in <module>
from impacket.dcerpc.v5 import nrpc, epm
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\nrpc.py", line 30, in <module>
from impacket.dcerpc.v5.samr import OLD_LARGE_INTEGER
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\samr.py", line 29, in <module>
from impacket.dcerpc.v5.rpcrt import DCERPCException
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\rpcrt.py", line 24, in <module>
from Cryptodome.Cipher import ARC4
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Cipher\__init__.py", line 27, in <module>
from Cryptodome.Cipher._mode_ecb import _create_ecb_cipher
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Cipher\_mode_ecb.py", line 35, in <module>
raw_ecb_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_ecb", """
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\_raw_api.py", line 308, in load_pycryptodome_raw_lib
raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))
OSError: Cannot load native module 'Cryptodome.Cipher._raw_ecb': Trying '_raw_ecb.cp38-win_amd64.pyd': cannot load library 'C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\..\Cipher\_raw_ecb.cp38-win_amd64.pyd': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\Users\\bhanney\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\Cryptodome\\Util\\..\\Cipher\\_raw_ecb.cp38-win_amd64.pyd', Trying '_raw_ecb.pyd': cannot load library 'C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\..\Cipher\_raw_ecb.pyd': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\Users\\bhanney\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\Cryptodome\\Util\\..\\Cipher\\_raw_ecb.pyd'
Here is a link to the github script: https://github.com/SecuraBV/CVE-2020-1472 , let me know if anyone can assist because I have no clue what I'm doing wrong
Since you said you're a novice at Python, I'll try to help you.. but you should definetely take a look at the links provided in the first comment.
So, after the formalities, let's read your error message together..
C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages>zerologon.py Dc_Name IP_address
the error was caused by this command: zerologon.py Dc_Name IP_address
Traceback (most recent call last):
traceback will show the error at the top and their dependencies...
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\zerologon.py", line 3, in <module>
from impacket.dcerpc.v5 import nrpc, epm
the first line is located in your script, the zerologon.py, at line 3, where you try to run the following command: from impacket.dcerpc.v5 import nrpc, epm
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\nrpc.py", line 30, in <module>
from impacket.dcerpc.v5.samr import OLD_LARGE_INTEGER
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\samr.py", line 29, in <module>
from impacket.dcerpc.v5.rpcrt import DCERPCException
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\impacket\dcerpc\v5\rpcrt.py", line 24, in <module>
from Cryptodome.Cipher import ARC4
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Cipher\__init__.py", line 27, in <module>
from Cryptodome.Cipher._mode_ecb import _create_ecb_cipher
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Cipher\_mode_ecb.py", line 35, in <module>
raw_ecb_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_ecb", "")
File "C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\_raw_api.py", line 308, in load_pycryptodome_raw_lib
raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))
and here, in the last "File Error Message", we can see the root of your problem: the file \Python\Python38-32\Lib\site-packages\Cryptodome\Util\_raw_api.py, in line 308, tried to run the command: load_pycryptodome_raw_lib, but it generated an OSError...
OSError: Cannot load native module 'Cryptodome.Cipher._raw_ecb':
here we can see the OSError message: Cannot load native module 'Cryptodome.Cipher._raw_ecb', and the following part shows us the unsuccessful alternative attempts..
Trying '_raw_ecb.cp38-win_amd64.pyd':
cannot load library 'C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\..\Cipher\_raw_ecb.cp38-win_amd64.pyd': error 0x7e.
Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\Users\\bhanney\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\Cryptodome\\Util\\..\\Cipher\\_raw_ecb.cp38-win_amd64.pyd',
Trying '_raw_ecb.pyd': cannot load library 'C:\Users\bhanney\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\Cryptodome\Util\..\Cipher\_raw_ecb.pyd': error 0x7e.
Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\Users\\bhanney\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\Cryptodome\\Util\\..\\Cipher\\_raw_ecb.pyd'
Ok, so after executing this reading and understanding routine, we can try to find a solution to your problem, by looking at:
Cryptodome Docs
Cryptodome Github Issues
After doing this, you can even specify your search using the raw_ecb text, for example... which leads us to this page, that may be very useful for you:
ISSUES filtered by "_raw_ecb.pyd"
Or this one:
Error loading native modules #185
In this issue, the OP said the following:
"I solved it by installing the VC++ 2008 Redistributable as I could see
in dependencywalker that MSVCR90 was not found"
I know this doesn't clearly answer your question, but it may help you understand how you can fix your code in a more general way..

Why does python shelf module give an error at start up when opening file

I have been using the python shelf module to store face encodings from the python face-recognition module below. I did this to make the live image recognition process faster.
I then imported these encodings in another script using the shelf module again, assigned them to a variable, and use them further down my script. This all works fine in the python idle environment and when I run it from the terminal. However, on startup, the shelf module fails to import the data. Can anyone tell me why this happens at start-up? The error I get on the log file is below. I have been stuck on it for a few days now. Is there a better way of storing and reusing the encodings? Thanks in advance.
the bit of code that fails on start-up but runs fine otherwise
import shelve
shelfFile = shelve.open('face_encodings')
known_encodings = shelfFile['known_encodings']
known_names = shelfFile['known_names']
shelfFile.close()
the error on startup
Traceback (most recent call last): File "/usr/lib/python3.7/shelve.py", line 111, in __getitem__
value = self.cache[key]
KeyError: 'known_encodings'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Desktop/run/testing.py", line 4, in <module>
known_encodings = shelfFile['known_encodings']
File "/usr/lib/python3.7/shelve.py", line 113, in __getitem__
f = BytesIO(self.dict[key.encode(self.keyencoding)])
KeyError: b'known_encodings'
face-recognition module
https://pypi.org/project/face-recognition/

Unable to use CsvFileSource from beam_utils.sources in apache beam program on Cloud Dataflow

Unable to import CsvFileSource but able to install beam_utils.
I need this import to run the Cloud data flow program.
Code has -
from beam_utils.sources import CsvFileSource
Error message :
>>> from beam_utils.sources import CsvFileSource
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vk/.local/lib/python2.7/site-packages/beam_utils/sources.py", line 14, in <module>
class JsonLinesFileSource(beam.io.filebasedsource.FileBasedSource):
File "/home/vk/.local/lib/python2.7/site-packages/beam_utils/sources.py", line 17, in JsonLinesFileSource
compression_type=fileio.CompressionTypes.AUTO,
AttributeError: 'module' object has no attribute 'CompressionTypes'
>>>
I even tried import using python3.
any idea, how I can bypass.
Apache beam has recently updated and changed a few of their methods and attributes.
In particular, the fileio class is now filesystem. If you want to quickfix this, you can edit beam_utils source (python_home\lib\site-packages\beam_utils\sources.py) and replace 'fileio' for 'filesystem'. It should work ;)
If you take a look at the github repo (https://github.com/pabloem/beam_utils/blob/master/beam_utils/sources.py), the changes are already there. I guess it's a matter of time until they're added to pip!
I'm also getting the same error. I'm attemping to load csv into a dictionary and then write it to local (eventually to BQ).
argv = [
'--project={0}'.format(PROJECT),
'--staging_location=gs://{0}/'.format(BUCKET),
'--temp_location=gs://{0}/'.format(BUCKET),
#'--runner=DataflowRunner'
'--runner=DirectRunner'
]
p= beam.Pipeline(argv=argv)
rows = p | 'ReadCSV' >> beam.io.Read(CsvFileSource('gs://blahblah/file.csv')) | 'Write to file' >> beam.io.WriteToText('s
trings', file_name_suffix='.txt')```
-[snip]-
Apache Beam will soon support Python 3 only.
'You are using Apache Beam with Python 2. '
Traceback (most recent call last):
File "avg-ecom-rating.py", line 5, in <module>
from beam_utils.sources import CsvFileSource
File "/home/dlemon/env/local/lib/python2.7/site-packages/beam_utils/sources.py", line 14, in <module>
class JsonLinesFileSource(beam.io.filebasedsource.FileBasedSource):
File "/home/dlemon/env/local/lib/python2.7/site-packages/beam_utils/sources.py", line 17, in JsonLinesFileSource
compression_type=fileio.CompressionTypes.AUTO,
AttributeError: 'module' object has no attribute 'CompressionTypes'

Categories