No modulo 'QtCore' Found - Windows Docker Container
-
wrote on 9 Nov 2023, 16:57 last edited by
There is a .py running some prediction model in this container on client's virtual machine.
Files in deploy repository
enter image description here1 - Requirements file
matplotlib==3.4.3 dill==0.3.4 numpy==1.24.4 pandas==2.0.3 scikit-learn==1.1.3 scipy==1.10.1 seaborn==0.11.2 Orange3==3.34.0 PyQt5==5.15.9
2 .py script (the only problem is in PyQt5 import, especifically QtCore)
import os, sys import numpy as np import pandas as pd import logging import pickle import json from typing import List, Union from datetime import datetime, timedelta # import QtCore import PyQt5 logger = logging.getLogger("VOA.%s" % __name__) class VOAModel(): models_folder = os.path.dirname(__file__) #get .py file folder ...
- One of my attempts was to get the .pyd file of the module and import it locally inside .py but the same error was shown.
I am stuck in this error:
enter image description herePip freeze in container
enter image description herePython version in container
enter image description hereWhen installing the docker image all the requirements appear to be okay and installed, but when executing the process we have this error.
There is no internet connection on this virtual machine and there is just a shared directory to move files.
There is nothing with GUI in this process, it is just a machine learning model from orange that I dont know why use this module QtCore.
Have already tried to do some stuffs like download .whl files from this libs and install locally in container, change lib versions and so on, but nothing works. The only problem is the import of module.
Anyone have a clue?
How can I get this import QtCore error fixed? -
Hi and welcome to devnet,
What is this
PyQt5.QtCore.pyd
doing there ?
You should move it out of your project structure. -
Hi and welcome to devnet,
What is this
PyQt5.QtCore.pyd
doing there ?
You should move it out of your project structure.wrote on 9 Nov 2023, 20:37 last edited by@SGaist It was just some attemps to import the lib directly in the path structure, but it is there just as garbage, not being used
-
@SGaist It was just some attemps to import the lib directly in the path structure, but it is there just as garbage, not being used
@rodrigoleao so as I wrote, remove it.
Are you using a virtual environment ?
-
@rodrigoleao so as I wrote, remove it.
Are you using a virtual environment ?
wrote on 10 Nov 2023, 11:06 last edited by rodrigoleao 11 Oct 2023, 11:06@SGaist this is the dockerfile used for generate de container
#Windows Server 2016: #ARG WINDOWS_VERSION="10.0.14393.2248" #Windows Server 2019: ARG WINDOWS_VERSION="10.0.17763.737-amd64" FROM mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION} ARG PYTHON_PIP_VERSION=21.1.2 WORKDIR C:/Temp SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"] COPY ./environment/Python38.zip . RUN Expand-Archive -Path "Python38.zip" -Destination "C:/Python" WORKDIR C:/Python/Python38 COPY ./environment/get-pip-${PYTHON_PIP_VERSION}.py . RUN [String]::Format('@set PYTHON_PIP_VERSION={0}', $env:PYTHON_PIP_VERSION) | Out-File -FilePath 'pipver.cmd' -Encoding ASCII; \ Remove-Item -Path "python38._pth"; \ Expand-Archive -Path "python38.zip" -Destination "Lib/"; \ Remove-Item -Path "python38.zip"; \ New-Item -Type Directory -Path "DLLs"; FROM mcr.microsoft.com/windows/nanoserver:${WINDOWS_VERSION} COPY --from=0 C:\\Python\\Python38 C:\\Python\\Python38 ARG PYTHON_PIP_VERSION=21.1.2 ENV PORT=8090 # RUN cmd /c mklink C:\Python\Python38\python38.exe C:\Python\Python38\python.exe WORKDIR C:/Python/Python38 USER Administrator ENV PYTHONPATH C:\\Python\\Python38;C:\\Python\\Python38\\Scripts;C:\\Python\\Python38\\DLLs;C:\\Python\\Python38\\Lib;C:\\Python\\Python38\\Lib\\plat-win;C:\\Python\\Python38\\Lib\\site-packages RUN setx.exe /m PATH %PATH%;%PYTHONPATH% && \ setx.exe /m PYTHONPATH %PYTHONPATH% && \ setx.exe /m PIP_CACHE_DIR C:\Users\ContainerUser\AppData\Local\pip\Cache && \ reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f # RUN echo %PATH% # RUN echo %PYTHONPATH% # https://soooprmx.com/archives/6471 RUN assoc .py=Python.File && \ assoc .pyc=Python.CompiledFile && \ assoc .pyd=Python.Extension && \ assoc .pyo=Python.CompiledFile && \ assoc .pyw=Python.NoConFile && \ assoc .pyz=Python.ArchiveFile && \ assoc .pyzw=Python.NoConArchiveFile && \ ftype Python.ArchiveFile="C:\Python\Python38\python.exe" "%1" %* && \ ftype Python.CompiledFile="C:\Python\Python38\python.exe" "%1" %* && \ ftype Python.File="C:\Python\Python38\python.exe" "%1" %* && \ ftype Python.NoConArchiveFile="C:\Python\Python38\pythonw.exe" "%1" %* && \ ftype Python.NoConFile="C:\Python\Python38\pythonw.exe" "%1" %* RUN call C:\Python\Python38\pipver.cmd && \ %COMSPEC% /s /c "echo Installing pip==%PYTHON_PIP_VERSION% ..." && \ %COMSPEC% /s /c "C:\Python\Python38\python.exe C:\Python\Python38\get-pip-21.1.2.py --disable-pip-version-check --no-cache-dir pip==%PYTHON_PIP_VERSION% --no-warn-script-location" && \ echo Removing ... && \ del /f /q C:\Python\Python38\get-pip-21.1.2.py C:\Python\Python38\pipver.cmd && \ echo Checking installation... && \ echo python version && \ python --version && \ echo Verifying pip installation... && \ echo pip version && \ pip --version && \ echo Verification complete! WORKDIR C:/app COPY . . RUN pip install -r requirements.txt ENV ANALYZER_NAME=Q3_Cracker_Viscosidade ENV DELAY=30 ENV LOG_DIR=C:/logs ENV PORT=8090 CMD ["python", "api_analyzer.py"]
-
@SGaist this is the dockerfile used for generate de container
#Windows Server 2016: #ARG WINDOWS_VERSION="10.0.14393.2248" #Windows Server 2019: ARG WINDOWS_VERSION="10.0.17763.737-amd64" FROM mcr.microsoft.com/windows/servercore:${WINDOWS_VERSION} ARG PYTHON_PIP_VERSION=21.1.2 WORKDIR C:/Temp SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"] COPY ./environment/Python38.zip . RUN Expand-Archive -Path "Python38.zip" -Destination "C:/Python" WORKDIR C:/Python/Python38 COPY ./environment/get-pip-${PYTHON_PIP_VERSION}.py . RUN [String]::Format('@set PYTHON_PIP_VERSION={0}', $env:PYTHON_PIP_VERSION) | Out-File -FilePath 'pipver.cmd' -Encoding ASCII; \ Remove-Item -Path "python38._pth"; \ Expand-Archive -Path "python38.zip" -Destination "Lib/"; \ Remove-Item -Path "python38.zip"; \ New-Item -Type Directory -Path "DLLs"; FROM mcr.microsoft.com/windows/nanoserver:${WINDOWS_VERSION} COPY --from=0 C:\\Python\\Python38 C:\\Python\\Python38 ARG PYTHON_PIP_VERSION=21.1.2 ENV PORT=8090 # RUN cmd /c mklink C:\Python\Python38\python38.exe C:\Python\Python38\python.exe WORKDIR C:/Python/Python38 USER Administrator ENV PYTHONPATH C:\\Python\\Python38;C:\\Python\\Python38\\Scripts;C:\\Python\\Python38\\DLLs;C:\\Python\\Python38\\Lib;C:\\Python\\Python38\\Lib\\plat-win;C:\\Python\\Python38\\Lib\\site-packages RUN setx.exe /m PATH %PATH%;%PYTHONPATH% && \ setx.exe /m PYTHONPATH %PYTHONPATH% && \ setx.exe /m PIP_CACHE_DIR C:\Users\ContainerUser\AppData\Local\pip\Cache && \ reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f # RUN echo %PATH% # RUN echo %PYTHONPATH% # https://soooprmx.com/archives/6471 RUN assoc .py=Python.File && \ assoc .pyc=Python.CompiledFile && \ assoc .pyd=Python.Extension && \ assoc .pyo=Python.CompiledFile && \ assoc .pyw=Python.NoConFile && \ assoc .pyz=Python.ArchiveFile && \ assoc .pyzw=Python.NoConArchiveFile && \ ftype Python.ArchiveFile="C:\Python\Python38\python.exe" "%1" %* && \ ftype Python.CompiledFile="C:\Python\Python38\python.exe" "%1" %* && \ ftype Python.File="C:\Python\Python38\python.exe" "%1" %* && \ ftype Python.NoConArchiveFile="C:\Python\Python38\pythonw.exe" "%1" %* && \ ftype Python.NoConFile="C:\Python\Python38\pythonw.exe" "%1" %* RUN call C:\Python\Python38\pipver.cmd && \ %COMSPEC% /s /c "echo Installing pip==%PYTHON_PIP_VERSION% ..." && \ %COMSPEC% /s /c "C:\Python\Python38\python.exe C:\Python\Python38\get-pip-21.1.2.py --disable-pip-version-check --no-cache-dir pip==%PYTHON_PIP_VERSION% --no-warn-script-location" && \ echo Removing ... && \ del /f /q C:\Python\Python38\get-pip-21.1.2.py C:\Python\Python38\pipver.cmd && \ echo Checking installation... && \ echo python version && \ python --version && \ echo Verifying pip installation... && \ echo pip version && \ pip --version && \ echo Verification complete! WORKDIR C:/app COPY . . RUN pip install -r requirements.txt ENV ANALYZER_NAME=Q3_Cracker_Viscosidade ENV DELAY=30 ENV LOG_DIR=C:/logs ENV PORT=8090 CMD ["python", "api_analyzer.py"]
Why are you using a Windows based image to run a python workload rather than the official Python images ?
1/6