2018-10-31 11:50:41

Hi everyone,
I started playing with python a few weeks ago (comming from c#). I am really enjoying some of its features, but cannot solve a problem with screen reader output modules like UniversalSpeech or Tolk.

My code works fine when I execute it from the same folder, that is, opening the command line and going to my code path, then runing the script like: D:, cd myCodePath, py test.py.
However, when I try to run my code from another location like: py D:\myCodePath\test.py, I get always the same error (using both universalSpeech or Tolk), something like:

Traceback (most recent call last):
  File "d:\myCodePath\test.py", line 5, in <module>
    import UniversalSpeech
  File "d:\myCodePath\UniversalSpeech.py", line 2, in <module>
    __uspeech = __ctypes.cdll.UniversalSpeech
  File "C:\Python37\lib\ctypes\__init__.py", line 426, in __getattr__
    dll = self._dlltype(name)
  File "C:\Python37\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] specified module could not be found

How could I fix that? Probably I am doing something wrong but no idea smile

Thanks in advance!

Thumbs up

2018-10-31 16:17:43

Hi. What I can guess is that the dll files that should be next to your .py file aren't there. For example I know tolk needs tolk.dll, tolk.exp and tolk.lib I think. I'm 85% sure that this is why you get this error. The needed dlls are mentioned in tolk's readme.

Add me on skype: kianoosh.shakeri2
Or follow me on twitter @kianoosh shakeri

2018-11-01 06:44:51 (edited by magurp244 2018-11-01 07:59:01)

Launching the program from a different location changes the working directory, so when it goes to look for the required files, it won't find them. You'll need to check for the files directory and change the current working directory in your program with the sys and os libraries before you do anything else. Example:

#the script is called test.py
import os,sys

#print the Current Working Directory

#print the files directory, note this can contain other data

#change the current directory to the files directory, but
#remove the name of the file from the string.

#print new current working directory

For Tolk you'll need Tolk.py, Tolk.dll, and if your going with the x86 drivers you'll also need dolapi32.dll, nvdacontrollerclient32.dll, and SAAPI32.dll.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

Thumbs up +1

2018-11-01 13:41:26

Thanks for your feedback.Magurp244, good point, finally I understood what was happening. Just a quick question yes, totally dumy here): I use those modules as you explained, copying the corresponding module.py to my working directory, However, documentation provided with those modules suggests that you should install the pakage using the pip install command. What am I missing? In my experience, I can import the module when it is located on the same directory, and while installing it or not does not change anything :)Thanks!

Thumbs up

2018-11-01 23:44:52

Portability. If your going to distribute your script you'll need to have those files packed with it, either in the binary or the same folder.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

Thumbs up