dkager / tolk

Screen reader abstraction library.
GNU Lesser General Public License v3.0
92 stars 42 forks source link

Python: AttributeError: Tolk #23

Open chigkim opened 8 months ago

chigkim commented 8 months ago

I'm having a problem running the python example. It seems I'm missing something very basic, but I'd appreciate if someone could help.

I copied src\python\Tolk.py to examples\python. Then I copied the following dlls to examples\python. dolapi32.dll nvdaControllerClient32.dll nvdaControllerClient64.dll SAAPI32.dll SAAPI64.dll

I ran build.bat, and got no output no error. When I run python ConsoleApp.py, I get the error below.

Traceback (most recent call last):
  File "C:\Users\chigo\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py", line 450, in __getattr__
    dll = self._dlltype(name)
          ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\chigo\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py", line 379, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'Tolk' (or one of its dependencies). Try using the full path with constructor syntax.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\code\tolk\examples\python\ConsoleApp.py", line 16, in <module>
    import Tolk
  File "D:\code\tolk\examples\python\Tolk.py", line 11, in <module>
    _tolk = cdll.Tolk
            ^^^^^^^^^
  File "C:\Users\chigo\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py", line 452, in __getattr__
    raise AttributeError(name)
AttributeError: Tolk

Thanks so much!

beqabeqa473 commented 8 months ago

Hello. In python => 3.8 os.add_dll_directory was added to add dll directory locations and cwd is no longer added to path by default.

So, try to add dll directory to search path with os.add_dll_directory for example scriptDir and try again

On 2/11/24, chigkim @.***> wrote:

I'm having a problem running the python example. It seems I'm missing very basic, but I'd appreciate if someone could help.

I copied src\python\Tolk.py to examples\python. Then I copied the following dlls to examples\python. dolapi32.dll nvdaControllerClient32.dll nvdaControllerClient64.dll SAAPI32.dll SAAPI64.dll

I ran build.bat, and got no output no error. When I run python ConsoleApp.py, I get the error below.

Traceback (most recent call last):
  File
"C:\Users\chigo\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py",
line 450, in __getattr__
    dll = self._dlltype(name)
          ^^^^^^^^^^^^^^^^^^^
  File
"C:\Users\chigo\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py",
line 379, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'Tolk' (or one of its
dependencies). Try using the full path with constructor syntax.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\code\tolk\examples\python\ConsoleApp.py", line 16, in <module>
    import Tolk
  File "D:\code\tolk\examples\python\Tolk.py", line 11, in <module>
    _tolk = cdll.Tolk
            ^^^^^^^^^
  File
"C:\Users\chigo\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py",
line 452, in __getattr__
    raise AttributeError(name)
AttributeError: Tolk

Thanks so much!

-- Reply to this email directly or view it on GitHub: https://github.com/dkager/tolk/issues/23 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

-- with best regards Beqa Gozalishvili Tell: +995593454005 Email: @.*** Web: https://gozaltech.org Skype: beqabeqa473 Telegram: https://t.me/gozaltech facebook: https://facebook.com/gozaltech twitter: https://twitter.com/beqabeqa473 Instagram: https://instagram.com/beqa.gozalishvili

chigkim commented 8 months ago

Thanks for your reply, but still I can't get it to run. I added the following to ConsoleApp.py.

import os
os.add_dll_directory(os.path.dirname(__file__))

However, I get the error below.

D:\code\tolk\examples\python>python ConsoleApp.py
Traceback (most recent call last):
  File "C:\Users\chigo\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py", line 450, in __getattr__
    dll = self._dlltype(name)
          ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\chigo\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py", line 379, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: Could not find module 'Tolk' (or one of its dependencies). Try using the full path with constructor syntax.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\code\tolk\examples\python\ConsoleApp.py", line 18, in <module>
    import Tolk
  File "D:\code\tolk\examples\python\Tolk.py", line 13, in <module>
    _tolk = cdll.Tolk
            ^^^^^^^^^
  File "C:\Users\chigo\AppData\Local\Programs\Python\Python312\Lib\ctypes\__init__.py", line 452, in __getattr__
    raise AttributeError(name)
AttributeError: Tolk