No module named 'PyQt5.QtCore' running docker windows image that appear the module installed in pip freeze

78 views Asked by At

There is a .py running some prediction model in this container on client's virtual machine.

Files in deploy repository enter image description here

1 - 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
...
  1. 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 here

Pip freeze in container enter image description here

Python version in container enter image description here

When 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?

1

There are 1 answers

2
Michael Fitzmaurice On

I'm not familiar with that PyQt5 library, but from what I can see, it is a set of Python bindings to an underlying native C++ library. It's possible that you cannot import that Python module due to the underlying native library (or some part of it) not being present in the container.

To investigate this idea, I did the following:

I didn't have that native library installed on my machine, but I made a new virtual env and did pip install PyQt5. I then opened a Python console and was able to import PyQt5, but sure enough, import PyQt5.QtCore failed with a module not found error.

I then installed the QT native libraries (brew install qt5) on my laptop, cleaned out the virtual env and did pip install PyQt5 again. Now when I import PyQt5.QtCore, I get an error, but it isn't a module not found error (it's something from down inside the C++ native libraries).

So does the native QT package exist inside the container?