'Unable to import mlflow, getting ModuleNotFoundError: No module named 'mlflow'

Unable to import mlflow in a .py script.

ModuleNotFoundError: No module named 'mlflow'

The script runs in a python:3.7-stretch Docker container

Use requirements.txt to pip install packages.

(...)
sqlalchemy==1.4.1
psycopg2==2.8.6
mlflow==1.18.0
RUN pip3 install --default-timeout=5000 --use-deprecated=legacy-resolver -r /root/requirements.txt

Can see that it is installed.

root@abc:~# pip uninstall mlflow
Found existing installation: mlflow 1.18.0
Uninstalling mlflow-1.18.0:
  Would remove:
    /usr/local/bin/mlflow
    /usr/local/lib/python3.7/site-packages/mlflow-1.18.0.dist-info/*
    /usr/local/lib/python3.7/site-packages/mlflow/*
Proceed (y/n)? n

Can do an import from python shell.

root@abc:~# python
Python 3.7.10 (default, Feb 16 2021, 19:46:13)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import mlflow
>>>

But no joy when running from .py script.

Other packages installed from requirements.txt can be imported.

Any ideas what is wrong ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source