Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLflow: ImportError: cannot import name 'tarfile' from 'backports'` #218

Open
amotl opened this issue Aug 11, 2024 · 3 comments
Open

MLflow: ImportError: cannot import name 'tarfile' from 'backports'` #218

amotl opened this issue Aug 11, 2024 · 3 comments

Comments

@amotl
Copy link
Member

amotl commented Aug 11, 2024

@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)

@amotl
Copy link
Member Author

amotl commented Aug 11, 2024

Dear @nayanjha16,

thank you for writing in. Can I ask you to verify the version of setuptools you are running?

$ python3 -c 'import setuptools; print(setuptools.__version__)'
69.0.3

Also, did you restart the Kernel of your Juypter environment, in order to apply any updates to dependencies?

With kind regards,
Andreas.

NB: Any woes with most recent setuptools==71.x.x have been resolved. So, running the most recent version should also work, like pip install --upgrade setuptools.

@amotl
Copy link
Member Author

amotl commented Aug 11, 2024

Dear Nayan,

just checking back if your request has anything to do with CrateDB, so we may move it to the issue tracker at https://github.com/crate/mlflow-cratedb?

With kind regards,
Andreas.

@amotl
Copy link
Member Author

amotl commented Aug 16, 2024

Hi @nayanjha16.

Can you confirm the error you are observing is related to mlflow-cratedb in any way? I can't spot any relevant mentions in the error output you shared above.

With kind regards,
Andreas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant