MLflow: ImportError: cannot import name 'tarfile' from 'backports'` #218
Open
Description
@nayanjha16 reported an error. Thanks!
I am still facing the same issue even after changing the versions of setuptools. I tried downgrading it to <71 as well. Doesn't seem to work for me.
Still getting the error
ImportError: cannot import name 'tarfile' from 'backports'
on importing mlflow.
{
"name": "ImportError",
"message": "cannot import name 'tarfile' from 'backports' (c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\backports\\__init__.py)",
"stack": "---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\\AppData\\Local\\Temp\\ipykernel_25044\\2545141633.py in <module>
3 from sklearn.ensemble import RandomForestRegressor
4
----> 5 from mlflow import MlflowClient
c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\mlflow\\__init__.py in <module>
32
33 __version__ = VERSION
---> 34 from mlflow import (
35 artifacts, # noqa: F401
36 client, # noqa: F401
c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\mlflow\\models\\__init__.py in <module>
42 )
43 from mlflow.models.flavor_backend import FlavorBackend
---> 44 from mlflow.models.model import Model, get_model_info, set_model
45 from mlflow.models.model_config import ModelConfig
46 from mlflow.models.python_api import build_docker
c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\mlflow\\models\\model.py in <module>
26 from mlflow.utils.databricks_utils import get_databricks_runtime_version, is_in_databricks_runtime
27 from mlflow.utils.docstring_utils import LOG_MODEL_PARAM_DOCS, format_docstring
---> 28 from mlflow.utils.environment import (
29 _CONDA_ENV_FILE_NAME,
30 _PYTHON_ENV_FILE_NAME,
c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\mlflow\\utils\\environment.py in <module>
22 from mlflow.utils.os import is_windows
23 from mlflow.utils.process import _exec_cmd
---> 24 from mlflow.utils.requirements_utils import (
25 _infer_requirements,
26 _parse_requirements,
c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\mlflow\\utils\\requirements_utils.py in <module>
18
19 import importlib_metadata
---> 20 import pkg_resources # noqa: TID251
21 from packaging.requirements import Requirement
22 from packaging.version import InvalidVersion, Version
c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\pkg_resources\\__init__.py in <module>
93
94 import packaging.specifiers
---> 95 from jaraco.text import (
96 yield_lines,
97 drop_comment,
c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\setuptools\\_vendor\\jaraco\\text\\__init__.py in <module>
10
11 from jaraco.functools import compose, method_cache
---> 12 from jaraco.context import ExceptionTrap
13
14
c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\setuptools\\_vendor\\jaraco\\context.py in <module>
15
16 if sys.version_info < (3, 12):
---> 17 from backports import tarfile
18 else:
19 import tarfile
ImportError: cannot import name 'tarfile' from 'backports' (c:\\Users\\NayanAnand\\anaconda3\\lib\\site-packages\\backports\\__init__.py)"
}
Any suggestions on how to fix this.
Originally posted by @nayanjha16 in #201 (comment)
Metadata
Assignees
Labels
No labels