Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. DLL Problems - DLL load failed -> QtCore
Forum Updated to NodeBB v4.3 + New Features

DLL Problems - DLL load failed -> QtCore

Scheduled Pinned Locked Moved Solved Qt for Python
3 Posts 2 Posters 227 Views
  • 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.
  • B Offline
    B Offline
    Beersky
    wrote last edited by
    #1

    Hello,
    I've migrated from PyQt5 to PyQt6 and rewrote the code, but I'm encountering the issues while running the interface.
    Venv: Python 3.9
    PyQt6 version = 6.9.1
    PyQt6-Pq6 = 6.9.1
    IDE - Pycharm

    Here's the error message:

    Traceback (most recent call last):
      File "C:\Users\binkjac\Documents\Project\Lab_Project\epcm_control_source 1\gui.py", line 4, in <module>
        from PyQt6.QtCore import QTimer
    ImportError: DLL load failed while importing QtCore: The specified procedure could not be found.
    

    Source Code:

    
    import sys
    import configparser
    from PyQt6.QtCore import QTimer
    from PyQt6.QtWidgets import (QApplication, QMainWindow, QTextEdit, QComboBox,
                                 QPushButton, QVBoxLayout, QWidget, QHBoxLayout, QLabel,
                                 QLineEdit, QMessageBox,QFileDialog)
    from PyQt6.QtCore import QThread, pyqtSignal, QTimer
    from PyQt6 import uic
    from pyModbusTCP.client import ModbusClient
    from output_widget import OutputLabel, Clients
    from ok_bad_indicator import OBIndicator
    from protocol import protocol
    
    # Load config.ini
    config = configparser.ConfigParser()
    config.read("config.ini")
    
    # Create application and load UI
    app = QtWidgets.QApplication(sys.argv)
    window = uic.loadUi("EPCMgui.ui")
    
    # Find IP input fields and button
    pwr_ip_edit = window.findChild(QtWidgets.QLineEdit, "pwrIpEdit")
    dio_ip_edit = window.findChild(QtWidgets.QLineEdit, "dioIpEdit")
    save_ip_button = window.findChild(QtWidgets.QPushButton, "saveIpButton")
    
    # Load IPs from config
    pwr_addr = config.get("interface", "pwr", fallback="192.168.1.252")
    dio_addr = config.get("interface", "dio", fallback="192.168.1.251")
    pwr_ip_edit.setText(pwr_addr)
    dio_ip_edit.setText(dio_addr)
    
    # Create Modbus clients
    pwr_client = ModbusClient(host=pwr_addr, port=502, auto_open=True)
    disc_client = ModbusClient(host=dio_addr, port=502, auto_open=True)
    
    # Assign clients to OutputLabel widgets
    for widget in window.findChildren(OutputLabel):
        widget.client = Clients.PWR if "pwr" in widget.objectName() else Clients.DISC
        widget.modbusaddress = int(protocol.get(widget.objectName(), {}).get("address", 0))
        widget.dimension = protocol.get(widget.objectName(), {}).get("unit", "")
        widget.type10 = protocol.get(widget.objectName(), {}).get("type", OutputLabel.Value)
    
    # Update IP addresses dynamically
    def update_ip_addresses():
        new_pwr_ip = pwr_ip_edit.text()
        new_dio_ip = dio_ip_edit.text()
        config["interface"]["pwr"] = new_pwr_ip
        config["interface"]["dio"] = new_dio_ip
        with open("config.ini", "w") as configfile:
            config.write(configfile)
        pwr_client.host(new_pwr_ip)
        disc_client.host(new_dio_ip)
        print("Updated IPs:", new_pwr_ip, new_dio_ip)
    
    save_ip_button.clicked.connect(update_ip_addresses)
    
    # EPCM Power Control Logic
    epcm_button = window.findChild(QtWidgets.QPushButton, "epcmSSPowButtonON")
    epcm_confirm = window.findChild(QtWidgets.QPushButton, "epcmSSPowConfirmButton")
    
    def enable_confirm():
        epcm_confirm.setEnabled(True)
    
    def confirm_power_on():
        disc_client.write_single_coil(11, True)
        epcm_confirm.setEnabled(False)
    
    epcm_button.clicked.connect(enable_confirm)
    epcm_confirm.clicked.connect(confirm_power_on)
    
    # Periodic update
    def update_widgets():
        for widget in window.findChildren(OutputLabel):
            widget.update()
        # Update indicators
        window.findChild(OBIndicator, "fpmIntInd").ok = pwr_client.is_open()
        window.findChild(OBIndicator, "fpmCommsInd").ok = pwr_client.is_open()
        window.findChild(OBIndicator, "ioIntInd").ok = disc_client.is_open()
        window.findChild(OBIndicator, "ioCommsInd").ok = disc_client.is_open()
    
    timer = QTimer()
    timer.timeout.connect(update_widgets)
    timer.start(1000)
    
    # Show window
    window.show()
    sys.exit(app.exec())
    
    

    Visual Studio Redistributables installed, PyQt6 re-installed multiple times, Python3.dll and Python39.dll present in the Venv Scripts folder - I'm slowly loosing hope.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Beersky
      wrote last edited by
      #3

      Found the solution. PyQt6 6.9.1 is not compatible with Python below 3.10. Updating python version helped.

      Leaving for the future researchers.

      1 Reply Last reply
      2
      • hskoglundH Offline
        hskoglundH Offline
        hskoglund
        wrote last edited by
        #2

        Hi maybe an advice from this old thread might helplink text

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Beersky
          wrote last edited by
          #3

          Found the solution. PyQt6 6.9.1 is not compatible with Python below 3.10. Updating python version helped.

          Leaving for the future researchers.

          1 Reply Last reply
          2
          • SGaistS SGaist has marked this topic as solved

          • Login

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