Closed nguyenphucnamgiang closed 1 week ago
Hi @nguyenphucnamgiang could you please install the latest version of backports.tarfile>=1.2
in your enviornment and see if it works?
thank you for your reply! But this returns the same error
(base) C:\Users\namgi>conda install conda-forge::backports.tarfile
Channels:
- conda-forge
- defaults
- anaconda
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:\Users\namgi\anaconda3
added / updated specs:
- conda-forge::backports.tarfile
The following packages will be downloaded:
package | build
---------------------------|-----------------
backports.tarfile-1.2.0 | pyhd8ed1ab_0 32 KB conda-forge
------------------------------------------------------------
Total: 32 KB
The following NEW packages will be INSTALLED:
backports.tarfile conda-forge/noarch::backports.tarfile-1.2.0-pyhd8ed1ab_0
The following packages will be UPDATED:
openssl 3.3.2-h2466b09_0 --> 3.4.0-h2466b09_0
wordcloud 1.9.3-py311he736701_2 --> 1.9.4-py311he736701_0
Proceed ([y]/n)? y
Downloading and Extracting Packages:
Preparing transaction: done
Verifying transaction: failed
RemoveError: 'setuptools' is a dependency of conda and cannot be removed from
conda's operating environment.
(base) C:\Users\namgi>conda install conda-forge::backports.tarfile=1.2
Channels:
- conda-forge
- defaults
- anaconda
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:\Users\namgi\anaconda3
added / updated specs:
- conda-forge::backports.tarfile=1.2
The following NEW packages will be INSTALLED:
backports.tarfile conda-forge/noarch::backports.tarfile-1.2.0-pyhd8ed1ab_0
The following packages will be UPDATED:
openssl 3.3.2-h2466b09_0 --> 3.4.0-h2466b09_0
wordcloud 1.9.3-py311he736701_2 --> 1.9.4-py311he736701_0
Proceed ([y]/n)? y
Downloading and Extracting Packages:
Preparing transaction: done
Verifying transaction: failed
RemoveError: 'setuptools' is a dependency of conda and cannot be removed from
conda's operating environment.
Umm, is it a deadlock? You cannot install backports.tarfile>=1.2
because setuptools
don't work and setuptools
cannot work because you cannot install backports.tarfile>=1.2
?
Can you try the following:
backports.tarfile
backports.tarfile>=1.2
If that does not work, you might have to start a fresh virtual environment 😢.
I don't even have backports.tarfile in my base environment
(base) C:\Users\namgi>conda list backports.tarfile
# packages in environment at C:\Users\namgi\anaconda3:
#
# Name Version Build Channel
(base) C:\Users\namgi>
unfortunately, my goal is to update the base environment, so I need to fix this
I don't even have backports.tarfile in my base environment
Umm, backports
is supposed to be a namespace, so there might be other backports.*
packages installed that are interfering with this.
I can see that you have a file C:\Users\namgi\anaconda3\Lib\site-packages\backports\__init__.py
. That is weird and probably the origin of the problem because backports.tarfile
expects backports
to be a namespace.
I suppose you can try:
C:\Users\namgi\anaconda3\Lib\site-packages\backports\__init__.py
OR
C:\Users\namgi\anaconda3\Lib\site-packages\backports\__init__.py
to something else like _bkp.py
backports.tarfile>=1.2
or setuptools[core]
backports.tarfile>=1.2
is installed...The specific mechanics of the problem are described https://github.com/pypa/setuptools/issues/4508#issuecomment-2249216574.
I suppose that you can also try to install backports.tarfile>=1.2
using pip
instead of conda
, because pip
uses isolated build environments for the build dependencies and/or pre-built wheels (so the deadlock would not kick in).
it was unexpected, pip finally added an tarfile folder and fixed that import error, I can launch anaconda navigator, but the other setuptools remove error stays the same
(base) C:\Users\namgi>pip install backports.tarfile==1.2
Collecting backports.tarfile==1.2
Downloading backports.tarfile-1.2.0-py3-none-any.whl.metadata (2.0 kB)
Downloading backports.tarfile-1.2.0-py3-none-any.whl (30 kB)
Installing collected packages: backports.tarfile
Successfully installed backports.tarfile-1.2.0
(base) C:\Users\namgi>conda update -n base conda
Channels:
- conda-forge
- defaults
- anaconda
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:\Users\namgi\anaconda3
added / updated specs:
- conda
The following packages will be UPDATED:
openssl 3.3.2-h2466b09_0 --> 3.4.0-h2466b09_0
wordcloud 1.9.3-py311he736701_2 --> 1.9.4-py311he736701_0
Proceed ([y]/n)? y
Downloading and Extracting Packages:
Preparing transaction: done
Verifying transaction: failed
RemoveError: 'setuptools' is a dependency of conda and cannot be removed from
conda's operating environment.
(base) C:\Users\namgi>anaconda-navigator
QMimeDatabase: Error loading internal MIME data
An error has been encountered at line 1 of <internal MIME data>: Premature end of document.:
conda can list setuptools but then I try to update it, it cannot be found, is this normal behaviour?
(base) C:\Users\namgi> conda update --force setuptools
WARNING: The --force flag will be removed in a future conda release.
See 'conda update --help' for details about the --force-reinstall
and --clobber flags.
PackageNotInstalledError: Package is not installed in prefix.
prefix: C:\Users\namgi\anaconda3
package name: setuptools
(base) C:\Users\namgi> conda list setuptools
# packages in environment at C:\Users\namgi\anaconda3:
#
# Name Version Build Channel
setuptools 75.2.0 pypi_0 pypi
You mean the error ImportError: cannot import name 'tarfile' from 'backports' (C:\Users\namgi\anaconda3\Lib\site-packages\backports\__init__.py)
?
How come if backports.tarfile==1.2
is installed? Does the C:\Users\namgi\anaconda3\Lib\site-packages\backports\tarfile
directory exist?
conda can list setuptools but then I try to update it, it cannot be found, is this normal behaviour?
I am not a specialist in conda, so I don't know how to answer that question.
This issue seems to be the same as #4508, so it may be worth exploring the options discussed there.
ImportError: cannot import name 'tarfile' from 'backports'
is ok, like I mentioned above, using pip install, it successfully downloaded the tarfile folder and fixed that import error, now opening anaconda does not give import error anymore
but it does not solve the RemoveError: 'setuptools' is a dependency of conda and cannot be removed from conda's operating environment
you can see this still output that error
it was unexpected, pip finally added an tarfile folder and fixed that import error, I can launch anaconda navigator, but the other setuptools remove error stays the same
(base) C:\Users\namgi>pip install backports.tarfile==1.2 Collecting backports.tarfile==1.2 Downloading backports.tarfile-1.2.0-py3-none-any.whl.metadata (2.0 kB) Downloading backports.tarfile-1.2.0-py3-none-any.whl (30 kB) Installing collected packages: backports.tarfile Successfully installed backports.tarfile-1.2.0 (base) C:\Users\namgi>conda update -n base conda Channels: - conda-forge - defaults - anaconda Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: done ## Package Plan ## environment location: C:\Users\namgi\anaconda3 added / updated specs: - conda The following packages will be UPDATED: openssl 3.3.2-h2466b09_0 --> 3.4.0-h2466b09_0 wordcloud 1.9.3-py311he736701_2 --> 1.9.4-py311he736701_0 Proceed ([y]/n)? y Downloading and Extracting Packages: Preparing transaction: done Verifying transaction: failed RemoveError: 'setuptools' is a dependency of conda and cannot be removed from conda's operating environment. (base) C:\Users\namgi>anaconda-navigator QMimeDatabase: Error loading internal MIME data An error has been encountered at line 1 of <internal MIME data>: Premature end of document.:
Ah ok, thank you. that clarified the problem.
In this case, it seems like something to be discussed with conda
maintainers, as it looks like a behaviour introduced by conda
itself.
thank you @abravalheri, I will move to conda now
Thank you. I will close the issue now as a duplicate of https://github.com/pypa/setuptools/issues/4508.
setuptools version
setuptools==75.2.0
Python version
Python 3.11.5
Environment information
Conda base environment
Description
I tried to update anaconda navigator using
conda update -n base conda
, but it then ran into this errorI tried debugging but I cannot find anything helpful. After that, I opened anaconda navigator but It didn't work, I then used
anaconda-navigator
in anaconda prompt then find thisI search many issues ImportError: cannot import name 'tarfile' from 'backports' #5, [BUG] 71.0.0 fails with backports.tarfile on Python 3.8 when other backports imported #4476, Reset the backports module when enabling vendored packages. #4486, Setup: Fix package installation woes with setuptools/backports.tarfile, and PyInstaller #201, [BUG] 71.0.0 fails PyInstaller builds #4477, [BUG] 71.0.4 and 71.1.0 fail with ImportError: cannot import name 'tarfile' from 'backports' #4509
the common solution is to change version but what should i downgrade to