Setup: Fix package installation woes with setuptools/backports.tarfile, and PyInstaller#201
Merged
Setup: Fix package installation woes with setuptools/backports.tarfile, and PyInstaller#201
setuptools/backports.tarfile, and PyInstaller#201Conversation
/path/to/lib/python3.8/site-packages/setuptools/_vendor/jaraco/context.py:17: ImportError ImportError: cannot import name 'tarfile' from 'backports' (/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/backports/__init__.py)
PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_importlib_metadata required by hook for module /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/PyInstaller/hooks/hook-importlib_metadata.py.
4d87261 to
a4ba5e8
Compare
ImportError: cannot import name 'tarfile' from 'backports'setuptools/backports.tarfile, and PyInstaller
This was referenced Jul 18, 2024
|
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 {
"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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
About
Check why GH-196 fails, and resolve it.
Investigations
Details I
Fails on Python 3.8.
-- https://github.com/crate/cratedb-toolkit/actions/runs/9982521975/job/27589490156?pr=196#step:6:229
Details II
Fails on all test matrix slots.
-- https://github.com/crate/cratedb-toolkit/actions/runs/9983011865/job/27589798960?pr=201#step:5:198
References
backports.tarfileon Python 3.8 when other backports imported pypa/setuptools#4476PyInstallerbuilds pypa/setuptools#4477Solution
Downgrading to
setuptools<71on the two spots where this happened worked just well, apparently?