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

AttributeError: module 'pkgutil' has no attribute 'ImpImporter' #12179

Closed
1 task done
shikingram opened this issue Jul 25, 2023 · 6 comments
Closed
1 task done

AttributeError: module 'pkgutil' has no attribute 'ImpImporter' #12179

shikingram opened this issue Jul 25, 2023 · 6 comments
Labels
resolution: wrong project Should be reported elsewhere

Comments

@shikingram
Copy link

Description

hi there! i find this error,and this issue,then i upgrade the pip version to 23.2.1 but i still got this error,can anyone help me to deal this problem?

  C:\Users\shikingram>pip --version
  pip 23.2.1 from E:\dev\py\Lib\site-packages\pip (python 3.12)
  
  C:\Users\shikingram>pip install numpy
  Collecting numpy
    Using cached numpy-1.25.1.tar.gz (10.4 MB)
    Installing build dependencies ... done
    Getting requirements to build wheel ... error
    error: subprocess-exited-with-error
  
    × Getting requirements to build wheel did not run successfully.
    │ exit code: 1
    ╰─> [33 lines of output]
        Traceback (most recent call last):
          File "E:\dev\py\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
            main()
          File "E:\dev\py\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
            json_out['return_val'] = hook(**hook_input['kwargs'])
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "E:\dev\py\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 112, in get_requires_for_build_wheel
            backend = _build_backend()
                      ^^^^^^^^^^^^^^^^
          File "E:\dev\py\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
            obj = import_module(mod_path)
                  ^^^^^^^^^^^^^^^^^^^^^^^
          File "E:\dev\py\Lib\importlib\__init__.py", line 90, in import_module
            return _bootstrap._gcd_import(name[level:], package, level)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "<frozen importlib._bootstrap>", line 1293, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1266, in _find_and_load
          File "<frozen importlib._bootstrap>", line 1216, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 400, in _call_with_frames_removed
          File "<frozen importlib._bootstrap>", line 1293, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1266, in _find_and_load
          File "<frozen importlib._bootstrap>", line 1237, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 841, in _load_unlocked
          File "<frozen importlib._bootstrap_external>", line 994, in exec_module
          File "<frozen importlib._bootstrap>", line 400, in _call_with_frames_removed
          File "C:\Users\shikingram\AppData\Local\Temp\pip-build-env-pk9ws81z\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module>
            import setuptools.version
          File "C:\Users\shikingram\AppData\Local\Temp\pip-build-env-pk9ws81z\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module>
            import pkg_resources
          File "C:\Users\shikingram\AppData\Local\Temp\pip-build-env-pk9ws81z\overlay\Lib\site-packages\pkg_resources\__init__.py", line 2172, in <module>
            register_finder(pkgutil.ImpImporter, find_on_path)
                            ^^^^^^^^^^^^^^^^^^^
        AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
        [end of output]
  
    note: This error originates from a subprocess, and is likely not a problem with pip.
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.

Expected behavior

No response

pip version

23.2.1

Python version

3.12

OS

windows

How to Reproduce

excute below script

pip install numpy

Output

No response

Code of Conduct

@shikingram shikingram added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Jul 25, 2023
@uranusjr
Copy link
Member

This error is from Numpy, not pip. Please report to Numpy.

@uranusjr uranusjr closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2023
@uranusjr uranusjr added resolution: wrong project Should be reported elsewhere and removed type: bug A confirmed bug or unintended behavior S: needs triage Issues/PRs that need to be triaged labels Jul 25, 2023
@shikingram
Copy link
Author

This error is from Numpy, not pip. Please report to Numpy.

I returned the py version to 3.11 to resolve, thank you

@derweisskrag
Copy link

Where this error might arise from in NumPy? I tried Pandas, and SciPy using py -m pip install to install those libraries. Also: py -m pip install wheel, setuptools; then I tried something like
from setuptools import setup, find_packages
setup(name = "gusml", version = "1.0", packages = find_packages())
Also, I tried setup(name = "gusml", version = "1.0", packages = find_packages(), install_requires=["numpy"]). The commands were py setup.py build, install.
Python told me to learn about pypa/build, and pypa/install, and drew my attention to poetry. Poetry was successfully installed and I used the same command:
py -m pip install poetry
This triggered installation and failed due to CARGO; after installing CARGO, Python could install Poetry using PIP.
Another remark: I am not any skilled, but I tried py -m venv myenv and then installed all those things: setuptools, wheel, and ran pip install numpy. Same error. I went to the source code of the error contained in Lib\site-packages\pkg_resources_init_.py, and changed ImpImported to zipimporter. Nothing changed. Then I deleted the code, saving it beforehand, and tried again. Same error. This further indicates that the problem is in Numpy.

Any advice where to look out for it?

@matteius
Copy link
Member

matteius commented Aug 5, 2023

We are also running into this error trying to support python 3.12 in pipenv. https://github.com/pypa/pipenv/actions/runs/5772265760/job/15647071533

  File "/home/runner/.local/share/virtualenvs/pipenv-8mdnxyxu-tests-L1prRAXM/lib/python3.12/site-packages/pip/_internal/metadata/base.py", line 612, in iter_all_distributions
    for dist in self._iter_distributions():
  File "/home/runner/.local/share/virtualenvs/pipenv-8mdnxyxu-tests-L1prRAXM/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py", line 176, in _iter_distributions
    for dist in finder.find_eggs(location):
  File "/home/runner/.local/share/virtualenvs/pipenv-8mdnxyxu-tests-L1prRAXM/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py", line 144, in find_eggs
    yield from self._find_eggs_in_dir(location)
  File "/home/runner/.local/share/virtualenvs/pipenv-8mdnxyxu-tests-L1prRAXM/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py", line 111, in _find_eggs_in_dir
    from pip._vendor.pkg_resources import find_distributions
  File "/home/runner/.local/share/virtualenvs/pipenv-8mdnxyxu-tests-L1prRAXM/lib/python3.12/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2164, in <module>
    register_finder(pkgutil.ImpImporter, find_on_path)
                    ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

@derweisskrag
Copy link

derweisskrag commented Aug 5, 2023

#EDIT: reportlab, pygame were successfully installed. SciPy, Pandas, Numpy were not.
#Edit2: Read numpy/numpy#22623
#Edit3: Read https://github.com/search?q=repo%3Anumpy%2Fnumpy%20Python%2012&type=code
So far: Wait until Numpy is 1.26.0 or contribute to it.
I tried Poetry: SciPy, Numpy failed:

ChefBuildError

  Backend 'setuptools.build_meta:__legacy__' is not available.

  at D:\Python12\Lib\site-packages\poetry\installation\chef.py:147 in _prepare
      143│
      144│                 error = ChefBuildError("\n\n".join(message_parts))
      145│
      146│             if error is not None:
    → 147│                 raise error from None
      148│
      149│             return path
      150│
      151│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with numpy (1.25.2) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "numpy (==1.25.2)"'

So, we must run pip wheel --use-pep517 "numpy==1.25.2" and see if NumPy supports PEP 517. As the result is an error, same as above, NumPy turns out to not support the aforementioned PEP 517 (Build and Configuration of Packages without directly setup.py which is using setuptools). Thus, I must go and read NumPy code again, specifically about how it processes packages and what tools it uses. The possible issue is NumPY IS NOT COMPATIBLE with Python 12.1 version I downloaded, which is rereleased one.

@uranusjr
Copy link
Member

uranusjr commented Aug 6, 2023

Hi all, as explained above, the issue reported here is from setuptools, not pip. If you believe you are running into the same issue as in the top post, please report to setuptools instead. This is the issue tracker for pip, and posting here will not help with your issue in any way. The setuptools issue tracker can be found at https://github.com/pypa/setuptools/issues.

@matteius This is a different issue, tracked in #11501 and has been fixed in pip 23.2. Please open a new issue if you believe there has been a regression.

@pypa pypa locked as resolved and limited conversation to collaborators Aug 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: wrong project Should be reported elsewhere
Projects
None yet
Development

No branches or pull requests

4 participants