[BUG] ModuleNotFoundError: No module named 'mlflow'
See original GitHub issueWillingness to contribute
The MLflow Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the MLflow code base?
- No. I cannot contribute a bug fix at this time.
System information
- Have I written custom code (as opposed to using a stock example script provided in MLflow): I use the exact example
sklearn_elasticnet_wine
from MLFlow. - OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
- MLflow installed from (source or binary): pip
- MLflow version (run
mlflow --version
): 1.20.2 - Python version: 3.6.5
- npm version, if running the dev UI: NA
- Exact command to reproduce:
mlflow run sklearn_elasticnet_wine
Describe the problem
- Expected: To run successfully the example of sklearn_elasticnet_wine by running
mlflow run sklearn_elasticnet_wine
- Reality: Have
ModuleNotFoundError: No module named 'mlflow'
error.
Code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.
- Clone the MLFLow repo
cd examples
mlflow run sklearn_elasticnet_wine
Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
2021/10/01 16:37:19 INFO mlflow.projects.utils: === Created directory C:\Users\Admin\AppData\Local\Temp\tmpzyfvbj1q for downloading remote URIs passed to arguments of type 'path' ===
2021/10/01 16:37:19 INFO mlflow.projects.backend.local: === Running command 'conda activate mlflow-fef3fb3f401d7934c5d335df2b82655b31e59e85 && python train.py 0.5 0.1' in run with ID '5926bd275a8e4f3e98d6fa1077facc0c' ===
Traceback (most recent call last):
File "train.py", line 15, in <module>
import mlflow
ModuleNotFoundError: No module named 'mlflow'
2021/10/01 16:37:21 ERROR mlflow.cli: === Run (ID '5926bd275a8e4f3e98d6fa1077facc0c') failed ===
What component(s), interfaces, languages, and integrations does this bug affect?
Components
-
area/artifacts
: Artifact stores and artifact logging -
area/build
: Build and test infrastructure for MLflow -
area/docs
: MLflow documentation pages -
area/examples
: Example code -
area/model-registry
: Model Registry service, APIs, and the fluent client calls for Model Registry -
area/models
: MLmodel format, model serialization/deserialization, flavors -
area/projects
: MLproject format, project running backends -
area/scoring
: MLflow Model server, model deployment tools, Spark UDFs -
area/server-infra
: MLflow Tracking server backend -
area/tracking
: Tracking Service, tracking client APIs, autologging
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
No module named 'mlflow' when running a notebook
From the error description, it looks like the mlflow library is not present. You can use ML cluster as these type of cluster...
Read more >No module named 'mlflow.sklearn'; 'mlflow' is not a package ...
I am getting the below error. import mlflow.sklearn ModuleNotFoundError: No module named 'mlflow.sklearn'; 'mlflow' is not a package.
Read more >mlflow: problems with pip installation - Stack Overflow
7/site-packages, I get "ModuleNotFoundError: No module named 'mlflow' error when I try to run code that imports mlflow module. How should I fix ......
Read more >ModuleNotFoundError: No module named 'mlflow'
Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'mlflow' How to remove the ModuleNotFo.
Read more >Quickstart — MLflow 2.0.1 documentation
By default mlflow run installs all dependencies using virtualenv. To run a project without using virtualenv , you can provide the --env-manager=local option...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for your detailed response and new infomation!
It is interesting to see this behavior. Based on your analysis, it seems it is a potential bug in conda on different OS. Will follow up on this issue more.
Hi, thank you for your dedicated response. Based on your response and some trials, somehow I found out the problem and fixed this, though I don’t understand why the issue occurs.
The issue is about activating multiple conda environments makes the second-activated environment uses Python from the
base
environment instead.base
environment (in this case,test_mlflow
environment) and runmlflow run
, it yields an issue of Python is from thebase
environment.Step to reproduce:
test_mlflow
with Python +MLFlow
installed.test_mlflow
& runmlflow run sklearn_elasticnet_wine
mlflow_<serial_number>
), runs the project and yields the error we talked about.Reproduce again the error in more handy way:
See the warning up there?
According to your answer, it seems that this does not happen on your side if the
mlflow_test
environment has Python in it, so my biggest guest is from the Conda behaviour on Windows OS, but yeah, still my guess, I haven’t paid more time researching on the root cause.Solution to make it works:
base
environmentmlflow run sklearn_elasticnet_wine
from thebase
environment