win32com module not found - python-3.x

I am trying to get pyttsx3 up and running on my computer. I did pip install pyttsx3 and pip install pypiwin32 I can see both of them in my python directory.
I type this code in to test it:
import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()
This is what comes out:
Traceback (most recent call last):
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\weakref.py", line 131, in getitem
o = self.datakey
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Danny\Desktop\python text to speech.py", line 9, in
engine = pyttsx3.init()
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "C:\Users\Danny\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\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\driver.py", line 77, in init
self._driver = self._module.buildDriver(weakref.proxy(self))
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 22, in buildDriver
return SAPI5Driver(proxy)
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 41, in init
self.setProperty('voice', self.getProperty('voice'))
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 83, in setProperty
self._tts.Voice = token
File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\win32com\client\dynamic.py", line 549, in setattr
self.oleobj.Invoke(entry.dispid, 0, invoke_type, 0, value)
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
I tried the same thing on another computer that already had both installed, and got the same output. Any idea what is going on with the win32com? I have no experience with it and am pretty lost. Thanks.

Ok, so I found the answer looking at other problems that were related to the win32com module. Basically what you need to do is navigate to your python scripts folder (in my case: C:\Users\Danny\AppData\Local\Programs\Python\Python36\Scripts) and run pywin32_postinstall. Upon running that script, it works perfectly!
Cheers!

Related

Autocomplete-Python not working, ATOM, Error from jed, grammer 3.9.txt not found

I upgraded my python version from 3.8 to 3.9. I was using autocomplete-Pythonn extension. And an error came in my atom editor. That grammer3.9.txt not found.
Looks like this error originated from Jedi. Please do not report such issues in autocomplete-python issue tracker. Report them directly to Jedi. Turn off outputProviderErrors setting to hide such errors in future. Traceback output:
*Traceback (most recent call last):
File "C:\Users\hp.atom\packages\autocomplete-python\lib\jedi\parser_init_.py", line 56, in load_grammar
return _loaded_grammars[path]
KeyError: 'C:\Users\hp\.atom\packages\autocomplete-python\lib\jedi\parser\grammar3.9.txt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\hp.atom\packages\autocomplete-python\lib\completion.py", line 376, in watch
self._process_request(request)
File "C:\Users\hp.atom\packages\autocomplete-python\lib\completion.py", line 338, in process_request
script = jedi.api.Script(
File "C:\Users\hp.atom\packages\autocomplete-python\lib\jedi\api_init.py", line 126, in init
self.grammar = load_grammar(version='%s.%s' % sys.version_info[:2])
File "C:\Users\hp.atom\packages\autocomplete-python\lib\jedi\parser_init.py", line 58, in load_grammar
return _loaded_grammars.setdefault(path, generate_grammar(path))
File "C:\Users\hp.atom\packages\autocomplete-python\lib\jedi\parser\pgen2\pgen.py", line 393, in generate_grammar
p = ParserGenerator(filename)
File "C:\Users\hp.atom\packages\autocomplete-python\lib\jedi\parser\pgen2\pgen.py", line 18, in init
stream = open(filename)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\hp\.atom\packages\autocomplete-python\lib\jedi\parser\grammar3.9.txt'
I came up with this error last time. But then I Just renamed the file grammer3.7 to grammer3.8. But I do not think this is the right way to do so.

anaconda navigator will no longer start even through cmd, won't install or update or manage environments

I'm new to django and using the anaconda cloud environment. Its been working well for 3 months plus but as of 7-24-2018 it is just stop to launch the navigator or open through cmd. I can't manage environments or install packages. Using the anaconda prompt also gives me the same error upon launching. It started when I wanted to install django-Oscar, but not having its dependencies I was forced to install the packages manually which in turn needed cytoolz that needs Microsoft Visual C++ build tools which I got to install as well but the error persists. Please help me!
Copy/Paste of CMD Traceback:
C:\Users\kaukau\Desktop>conda --version conda 4.5.4
C:\Users\kaukau\Desktop>anaconda-navigator Traceback (most recent call
last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\qtpy__init__.py", line
169, in
from PySide import version as PYSIDE_VERSION # analysis:ignore ModuleNotFoundError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\Scripts\anaconda-navigator-script.py", line
6, in
from anaconda_navigator.app.main import main File "C:\Users\kaukau\Anaconda3\lib\site-packages\anaconda_navigator\app\main.py",
line 22, in
from anaconda_navigator.utils.conda import is_conda_available File
"C:\Users\kaukau\Anaconda3\lib\site-packages\anaconda_navigator\utils__init__.py",
line 15, in
from qtpy.QtGui import QIcon File "C:\Users\kaukau\Anaconda3\lib\site-packages\qtpy__init__.py", line
175, in
raise PythonQtError('No Qt bindings could be found') qtpy.PythonQtError: No Qt bindings could be found
C:\Users\kaukau\Desktop>conda install qt --force Traceback (most
recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 819, in call
return func(*args, **kwargs) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
73, in _main
from ..base.context import context File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\Scripts\conda-script.py", line 10, in
sys.exit(main()) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
113, in main
return conda_exception_handler(_main, *args) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 1112, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 822, in call
return self.handle_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 864, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 876, in handle_unexpected_exception
self.print_unexpected_error_report(error_report) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 932, in print_unexpected_error_report
from .base.context import context File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
97, in main
from ..activate import main as activator_main File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\activate.py", line
11, in
from .base.context import ROOT_ENV_NAME, context, locate_prefix_by_name File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 42, in
from cytoolz.dicttoolz import merge File "C:\Users\kaukau\Anaconda3\lib\site-packages\cytoolz__init__.py",
line 1, in
from .itertoolz import * ModuleNotFoundError: No module named 'cytoolz.itertoolz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\kaukau\Anaconda3\Scripts\conda-script.py", line 10, in
sys.exit(main()) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\cli\main.py", line
110, in main
return ExceptionHandler().handle_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 864, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 876, in handle_unexpected_exception
self.print_unexpected_error_report(error_report) File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\exceptions.py",
line 932, in print_unexpected_error_report
from .base.context import context File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda\base\context.py",
line 23, in
from ..common.configuration import (Configuration, LoadError, MapParameter, PrimitiveParameter, File
"C:\Users\kaukau\Anaconda3\lib\site-packages\conda\common\configuration.py",
line 47, in
from .._vendor.toolz.functoolz import excepts File "C:\Users\kaukau\Anaconda3\lib\site-packages\conda_vendor\toolz\functoolz.py",
line 501
f.name for f in reversed((self.first,) + self.funcs),
^ SyntaxError: Generator expression must be parenthesized
I've just found out that I cant even use any conda commands except the : >conda --version< command only.
Please help me resolve this issue without uninstalling then reinstalling anaconda completely
Sorry to waste your time, I solved it by reinstalling anaconda completely and every project started working again....thanks to those who read it, the effort is appreciated.
It usually happen when you directly download and insall anaconda normally form its website.
Updating anaconda solved this issue for me in Manjaro and will surely work on Windows as well.
use conda update anaconda-navigator command to Update Anaconda.
If it doesn't starts, restart your pc and try to open it again.

psutil.AccessDenied Error while trying to load StanfordCoreNLP

I'm trying to load the package StanfordCoreNLP to get the correct parsing for the movie reviews presented in their page (https://nlp.stanford.edu/sentiment/treebank.html): (I'm using MAC)
nlp = StanfordCoreNLP("/Users//NLP_models/stanford-corenlp-full-2018-01-31")
But get the error:
Traceback (most recent call last):
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 295, in wrapper
return fun(self, *args, **kwargs)
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 480, in connections
rawlist = cext.proc_connections(self.pid, families, types)
PermissionError: [Errno 1] Operation not permitted
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 2411, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1802, in run
launch(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
...
...
...
File "/Users/anaconda3/lib/python3.6/site-packages/stanfordcorenlp/corenlp.py", line 79, in __init__
if port_candidate not in [conn.laddr[1] for conn in psutil.net_connections()]:
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/__init__.py", line 2191, in net_connections
return _psplatform.net_connections(kind)
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 229, in net_connections
cons = Process(pid).connections(kind)
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 300, in wrapper
raise AccessDenied(self.pid, self._name)
psutil.AccessDenied: psutil.AccessDenied (pid=5488)
I tried
conda update conda
conda update anaconda-navigator
conda update navigator-updater
But it didn't help.
Any ideas??
Thanks!!
I have the same problem, and I got it work by running the code using sudo like below:
sudo /Users/edamame/workspace/git/chinese_nlp/venv/bin/python3 chinese_segmenter1.py
Hope this works for you as well.
Same problem here.
A lot of discussion of this points to https://github.com/ContinuumIO/anaconda-issues/issues/1984, which suggests updating to the latest Navigator, and running as root (via sudo).
I've tried both and see no change at all (you may be more fortunate).
https://github.com/Lynten/stanford-corenlp/issues/26 references a tweaked version of corenlp.py that claims to avoid the problem, though I haven't gotten it to work either.
This problem seems to be specific to Mac OS X which would not allow Python to check the current port.
Comment this portion of code of corenlp.py file:
if self.port is None:
for port_candidate in range(9000, 65535):
if port_candidate not in [conn.laddr[1] for conn in psutil.net_connections()]:
self.port = port_candidate
break
if self.port in [conn.laddr[1] for conn in psutil.net_connections()]:
raise IOError('Port ' + str(self.port) + ' is already in use.')
Replace by this line:
self.port = 9999
Source: https://github.com/Lynten/stanford-corenlp/issues/26#issuecomment-445507811
Another solution is to run StanfordCoreNLP with a sudo command line.

Pymunk drawing utils not working

I am struggling to setup pymunk on my Ubuntu 16.04. I am using virtualenv, I have Python 3.5.2, pymunk 5.3.0 and cffi 1.11.0 installed.
I tried a very simple code first; basically, I created an empty Space and called step on it and everything worked smoothly. However, when I try to visualize it and create DrawOptions instance, I get strange errors, which I can't decipher. Also, I tried matplotlib_util and pygame_util, but both failed to create DrawOptions.
This is the code snippet I used:
import pymunk
import pyglet
import pymunk.pyglet_util
s = pymunk.Space()
options = pymunk.pyglet_util.DrawOptions()
s.debug_draw(options)
# s.step(0.02)
This is the output I get:
Loading chipmunk for Linux (64bit) [/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/pymunk/libchipmunk.so]
Traceback (most recent call last):
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/cffi-1.11.0-py3.5-linux-x86_64.egg/cffi/api.py", line 167, in _typeof
result = self._parsed_types[cdecl]
KeyError: 'typedef void (*cpSpaceDebugDrawCircleImpl)(cpVect pos, cpFloat angle, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data)'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/cffi-1.11.0-py3.5-linux-x86_64.egg/cffi/cparser.py", line 276, in _parse
ast = _get_parser().parse(fullcsource)
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/pycparser/c_parser.py", line 152, in parse
debug=debuglevel)
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/pycparser/ply/yacc.py", line 331, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/pycparser/ply/yacc.py", line 1199, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/pycparser/ply/yacc.py", line 193, in call_errorfunc
r = errorfunc(token)
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/pycparser/c_parser.py", line 1761, in p_error
column=self.clex.find_tok_column(p)))
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/pycparser/plyparser.py", line 66, in _parse_error
raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: <cdef source string>:2:16: before: cpSpaceDebugDrawCircleImpl
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "pmtest2.py", line 5, in <module>
options = pymunk.pyglet_util.DrawOptions()
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/pymunk/pyglet_util.py", line 89, in __init__
super(DrawOptions, self).__init__()
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/pymunk/space_debug_draw_options.py", line 51, in __init__
#ffi.callback("typedef void (*cpSpaceDebugDrawCircleImpl)"
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/cffi-1.11.0-py3.5-linux-x86_64.egg/cffi/api.py", line 375, in callback
cdecl = self._typeof(cdecl, consider_function_as_funcptr=True)
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/cffi-1.11.0-py3.5-linux-x86_64.egg/cffi/api.py", line 170, in _typeof
result = self._typeof_locked(cdecl)
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/cffi-1.11.0-py3.5-linux-x86_64.egg/cffi/api.py", line 155, in _typeof_locked
type = self._parser.parse_type(cdecl)
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/cffi-1.11.0-py3.5-linux-x86_64.egg/cffi/cparser.py", line 476, in parse_type
return self.parse_type_and_quals(cdecl)[0]
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/cffi-1.11.0-py3.5-linux-x86_64.egg/cffi/cparser.py", line 479, in parse_type_and_quals
ast, macros = self._parse('void __dummy(\n%s\n);' % cdecl)[:2]
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/cffi-1.11.0-py3.5-linux-x86_64.egg/cffi/cparser.py", line 278, in _parse
self.convert_pycparser_error(e, csource)
File "/home/wm/.virtualenvs/cv/lib/python3.5/site-packages/cffi-1.11.0-py3.5-linux-x86_64.egg/cffi/cparser.py", line 307, in convert_pycparser_error
raise CDefError(msg)
cffi.error.CDefError: cannot parse "typedef void (*cpSpaceDebugDrawCircleImpl)(cpVect pos, cpFloat angle, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data)"
<cdef source string>:2:16: before: cpSpaceDebugDrawCircleImpl
What do you think is causing that? Is that the python version I use, or maybe cffi compilation is faulty?
This error happens because there was a new version of pycparser (which is used by cffi) released, and that version breaks pymunk 5.3.0 and earlier versions. Yesterday I made a new release of Pymunk, 5.3.1 with a workaround for the problem. If you try to update your Pymunk version to 5.3.1 it should work.

Python 2.5 Import dll AttributeError

I have a program that runs peachy in Py2.4. I import the TobiiPlugin.dll file and then run my scripts.
import TobiiPlugin as tobii
tobii.setGazeSubjectProfile(3, 0)
However, when I moved the code to Py2.5 it gets angry at me and I get
Traceback (most recent call last):
File "C:\tobiiDll\TobiiPlugin\Debug\logger_speech.py", line 274, in <module>
main()
File "C:\tobiiDll\TobiiPlugin\Debug\logger_speech.py", line 242, in main
tobii.setGazeSubjectProfile(3, 0)
File "C:\Python25\lib\ctypes\__init__.py", line 325, in __getattr__
func = self.__getitem__(name)
File "C:\Python25\lib\ctypes\__init__.py", line 330, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'setGazeSubjectProfile' not found
>>>
How did everything manage to go missing? It's not just this function either. I tried others from the DLL and they didn't work either. Thank you!
For some reason the Tobii SDK 3.0 Beta only works with Python 2.4 or Python 2.6.

Resources