Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. there seems to be an incompatibility between PySide6 and pyttsx3
Forum Updated to NodeBB v4.3 + New Features

there seems to be an incompatibility between PySide6 and pyttsx3

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 947 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    atmega328
    wrote on last edited by atmega328
    #1

    Hello. below is simple code for regenerating error :

    import sys
    import pyttsx3
    from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
    
    class MainWindow(QMainWindow):
        def __init__(self):
            super().__init__()
    
            self.button = QPushButton("Play")
            self.button.clicked.connect(self.play_sound)
            self.setCentralWidget(self.button)
    
            self.engine = pyttsx3.init()
    
        def play_sound(self):
            self.engine.say("hello")
            self.engine.runAndWait()
    
    if __name__ == "__main__":
        app = QApplication(sys.argv)
        window = MainWindow()
        window.show()
        sys.exit(app.exec())
    

    OS : Windowss 11 laptop
    IDE : Pycharm(Anaconda), virtual env
    Python Ver : 3.9.16

    I suspect there is a collision between ShibokenSupport in Qt & pyttsx3, as shown by this error message :

    C:\Users\hlfan.conda\envs\UAV_GCS\python.exe C:/Users/hlfan/PycharmProjects/speak_practice/main.py
    Traceback (most recent call last):
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3_init_.py", line 20, in init
    eng = _activeEngines[driverName]
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\weakref.py", line 137, in getitem
    o = self.datakey
    KeyError: None

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\tokenize.py", line 330, in find_cookie
    line_string = line.decode('utf-8')
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:\Users\hlfan\PycharmProjects\speak_practice\main.py", line 21, in <module>
    window = MainWindow()
    File "C:\Users\hlfan\PycharmProjects\speak_practice\main.py", line 13, in init
    self.engine = pyttsx3.init()
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3_init_.py", line 22, in init
    eng = Engine(driverName, debug)
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3\engine.py", line 30, in init
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3\driver.py", line 50, in init
    self.module = importlib.import_module(name)
    File "C:\Users\hlfan.conda\envs\UAV_GCS\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 680, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 850, in exec_module
    File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3\drivers\sapi5.py", line 10, in <module>
    import pythoncom
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pythoncom.py", line 2, in <module>
    import pywintypes
    File "shibokensupport/signature/loader.py", line 61, in feature_imported
    File "shibokensupport/feature.py", line 137, in feature_imported
    File "shibokensupport/feature.py", line 148, in _mod_uses_pyside
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\inspect.py", line 1024, in getsource
    lines, lnum = getsourcelines(object)
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\inspect.py", line 1006, in getsourcelines
    lines, lnum = findsource(object)
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\inspect.py", line 831, in findsource
    lines = linecache.getlines(file, module.dict)
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\linecache.py", line 46, in getlines
    return updatecache(filename, module_globals)
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\linecache.py", line 136, in updatecache
    with tokenize.open(fullname) as fp:
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\tokenize.py", line 394, in open
    encoding, lines = detect_encoding(buffer.readline)
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\tokenize.py", line 371, in detect_encoding
    encoding = find_cookie(first)
    File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\tokenize.py", line 335, in find_cookie
    raise SyntaxError(msg)
    SyntaxError: invalid or missing encoding declaration for 'C:\Users\hlfan\.conda\envs\UAV_GCS\lib\site-packages\pywin32_system32\pywintypes39.dll'

    Process finished with exit code 1

    What I tried :
    I tried reinstalling packages with different versions, but it didn't work. Using only PySide6 or only pyttsx3 works great, but if I combine them, I get an error. It seems that there is an incompatibility between these two libraries.

    A 1 Reply Last reply
    0
    • A atmega328

      Hello. below is simple code for regenerating error :

      import sys
      import pyttsx3
      from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
      
      class MainWindow(QMainWindow):
          def __init__(self):
              super().__init__()
      
              self.button = QPushButton("Play")
              self.button.clicked.connect(self.play_sound)
              self.setCentralWidget(self.button)
      
              self.engine = pyttsx3.init()
      
          def play_sound(self):
              self.engine.say("hello")
              self.engine.runAndWait()
      
      if __name__ == "__main__":
          app = QApplication(sys.argv)
          window = MainWindow()
          window.show()
          sys.exit(app.exec())
      

      OS : Windowss 11 laptop
      IDE : Pycharm(Anaconda), virtual env
      Python Ver : 3.9.16

      I suspect there is a collision between ShibokenSupport in Qt & pyttsx3, as shown by this error message :

      C:\Users\hlfan.conda\envs\UAV_GCS\python.exe C:/Users/hlfan/PycharmProjects/speak_practice/main.py
      Traceback (most recent call last):
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3_init_.py", line 20, in init
      eng = _activeEngines[driverName]
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\weakref.py", line 137, in getitem
      o = self.datakey
      KeyError: None

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\tokenize.py", line 330, in find_cookie
      line_string = line.decode('utf-8')
      UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
      File "C:\Users\hlfan\PycharmProjects\speak_practice\main.py", line 21, in <module>
      window = MainWindow()
      File "C:\Users\hlfan\PycharmProjects\speak_practice\main.py", line 13, in init
      self.engine = pyttsx3.init()
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3_init_.py", line 22, in init
      eng = Engine(driverName, debug)
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3\engine.py", line 30, in init
      self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3\driver.py", line 50, in init
      self.module = importlib.import_module(name)
      File "C:\Users\hlfan.conda\envs\UAV_GCS\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 680, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 850, in exec_module
      File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pyttsx3\drivers\sapi5.py", line 10, in <module>
      import pythoncom
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\site-packages\pythoncom.py", line 2, in <module>
      import pywintypes
      File "shibokensupport/signature/loader.py", line 61, in feature_imported
      File "shibokensupport/feature.py", line 137, in feature_imported
      File "shibokensupport/feature.py", line 148, in _mod_uses_pyside
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\inspect.py", line 1024, in getsource
      lines, lnum = getsourcelines(object)
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\inspect.py", line 1006, in getsourcelines
      lines, lnum = findsource(object)
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\inspect.py", line 831, in findsource
      lines = linecache.getlines(file, module.dict)
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\linecache.py", line 46, in getlines
      return updatecache(filename, module_globals)
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\linecache.py", line 136, in updatecache
      with tokenize.open(fullname) as fp:
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\tokenize.py", line 394, in open
      encoding, lines = detect_encoding(buffer.readline)
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\tokenize.py", line 371, in detect_encoding
      encoding = find_cookie(first)
      File "C:\Users\hlfan.conda\envs\UAV_GCS\lib\tokenize.py", line 335, in find_cookie
      raise SyntaxError(msg)
      SyntaxError: invalid or missing encoding declaration for 'C:\Users\hlfan\.conda\envs\UAV_GCS\lib\site-packages\pywin32_system32\pywintypes39.dll'

      Process finished with exit code 1

      What I tried :
      I tried reinstalling packages with different versions, but it didn't work. Using only PySide6 or only pyttsx3 works great, but if I combine them, I get an error. It seems that there is an incompatibility between these two libraries.

      A Offline
      A Offline
      atmega328
      wrote on last edited by
      #2

      @atmega328 Problem solved.

      SGaistS A 2 Replies Last reply
      0
      • A atmega328 has marked this topic as solved on
      • A atmega328

        @atmega328 Problem solved.

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @atmega328 Hi,

        What was the issue ?
        How did you fix it ?
        It might help other people.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • A atmega328

          @atmega328 Problem solved.

          A Offline
          A Offline
          Amin55
          wrote on last edited by
          #4

          @atmega328 Would you please share your solution? I faced the same problem using Pyside6 with dronecan!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved