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

Python 3.12 uses mim prompt module 'pkgutil' has no attribute 'ImpImporter‘ #242

Open
yzezeze opened this issue May 20, 2024 · 10 comments

Comments

@yzezeze
Copy link

yzezeze commented May 20, 2024

When using mim to install mmcv, an error message appears indicating that ImpImporter cannot be found. This attribute was removed in Python 3.12, which is suspected to be causing mim to be unusable.

Normal after changing the environment to Python 3.10.

The specific error display is as follows:

Traceback (most recent call last):
File "/home/zzbot/miniconda3/envs/UAV-WSL/bin/mim", line 5, in
from mim.cli import cli
File "/home/zzbot/miniconda3/envs/UAV-WSL/lib/python3.12/site-packages/mim/init.py", line 10, in
import setuptools # noqa: F401
^^^^^^^^^^^^^^^^^
File "/home/zzbot/miniconda3/envs/UAV-WSL/lib/python3.12/site-packages/setuptools/init.py", line 16, in
import setuptools.version
File "/home/zzbot/miniconda3/envs/UAV-WSL/lib/python3.12/site-packages/setuptools/version.py", line 1, in
import pkg_resources
File "/home/zzbot/miniconda3/envs/UAV-WSL/lib/python3.12/site-packages/pkg_resources/init.py", line 2172, in
register_finder(pkgutil.ImpImporter, find_on_path)
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

@yzezeze
Copy link
Author

yzezeze commented May 20, 2024

Looking forward to a reply!

@zhouzaida
Copy link
Collaborator

Hi, you can try to upgrade your pip with the following command.

pip install -U pip

@yzezeze
Copy link
Author

yzezeze commented May 20, 2024

Hi, you can try to upgrade your pip with the following command.

pip install -U pip

Thank you very much for your reply. I have tried this method and it did not solve the problem, so I speculate that the problem is caused by the Python version

@MrRaptorious
Copy link

https://stackoverflow.com/questions/77364550/attributeerror-module-pkgutil-has-no-attribute-impimporter-did-you-mean

"Due to the removal of the long-deprecated pkgutil.ImpImporter class, the pip command may not work for Python 3.12.

You just have to manually install pip for Python 3.12" with:

python -m ensurepip --upgrade
python -m pip install --upgrade setuptools

@MahdiZaman
Copy link

Hi @yzezeze , did you find a working solution to your problem? I have been facing the same issue. openmim works fine with my py3.10 at local, but for training on the server I need py3.12 (because of some distributed-data-parallel reqs) which is incompatible with openmim. Please comment if you found a solution.

@ruckc
Copy link

ruckc commented Aug 8, 2024

Running into this in a new virtualenv with Python 3.12.

Looks like pip install mim reverts setuptools to an old version which causes the issue. This is because openxlab has a ~= version requirement instead of a >= version.

$ python -m pip install --upgrade setuptools
Requirement already satisfied: setuptools in /home/ruckc/.cache/pypoetry/virtualenvs/triton-mmdetection-MNiodkYm-py3.12/lib/python3.12/site-packages (60.2.0)
Collecting setuptools
  Downloading setuptools-72.1.0-py3-none-any.whl.metadata (6.6 kB)
Downloading setuptools-72.1.0-py3-none-any.whl (2.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.3/2.3 MB 46.1 MB/s eta 0:00:00
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 60.2.0
    Uninstalling setuptools-60.2.0:
      Successfully uninstalled setuptools-60.2.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
openxlab 0.1.1 requires setuptools~=60.2.0, but you have setuptools 72.1.0 which is incompatible.
Successfully installed setuptools-72.1.0

@neleSuffo
Copy link

I still have the same error working in a virtualenv with Python 3.8.
(AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?)

Any updates on how to resolve the issue?

@chengwei-hust
Copy link

I still have the same error working in a virtualenv with Python 3.8. (AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?)

Any updates on how to resolve the issue?
I work fine in a virtualenv with Python 3.11... after I install python3.11-venv, python3.11-dev.

chengwei@AIHUB:$ . venv/bin/activate
(venv) chengwei@AIHUB:
$ pip list
Package Version


pip 24.0
setuptools 65.5.0

@btakita
Copy link

btakita commented Nov 19, 2024

I am not able to reproduce this issue on Python 3.12. However, a colleague has this issue. Has anyone had this issue then fixed it? What change needed to be done?

I'm running Python 3.12.7 & pip 24.3.1.

@MoRoBe-Work
Copy link

I'm using a conda environment. For me
conda install setuptools>=75.0.1
solved the issue. Might work with pip as well. 75.0.1 was the newest version available at the time and should probably be adjusted when using this in the future.

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

9 participants