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

"ModuleNotFoundError: No module named 'pyexpat'" when run pip install on embedded Python #11670

Closed
1 task done
bebound opened this issue Dec 21, 2022 · 3 comments
Closed
1 task done
Labels
resolution: wrong project Should be reported elsewhere

Comments

@bebound
Copy link

bebound commented Dec 21, 2022

Description

ModuleNotFoundError: No module named 'pyexpat' is raised when use pip install on embedded Python.
.\python.exe -c 'import xml.parsers.expat' works fine.

Related issue: Azure/azure-cli#24781

Expected behavior

No error raises

pip version

22.3.1

Python version

3.10.9

OS

Windows 11

How to Reproduce

  1. Download https://www.python.org/ftp/python/3.10.9/python-3.10.9-embed-win32.zip and extract it
  2. curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  3. python get-pip.py
  4. .\python.exe -m pip install pwinput

Output

Collecting pwinput
  Using cached pwinput-1.0.2.tar.gz (4.5 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\cli\base_command.py", line 160, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\cli\req_command.py", line 247, in wrapper
    return func(self, options, args)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\commands\install.py", line 400, in run
    requirement_set = resolver.resolve(
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 92, in resolve
    result = self._result = resolver.resolve(
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 348, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
    return bool(self._sequence)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 155, in __bool__
    return any(self)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 143, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 47, in _iter_built
    candidate = func()
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 206, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 297, in __init__
    super().__init__(
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 162, in __init__
    self.dist = self._prepare()
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 231, in _prepare
    dist = self._prepare_distribution()
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 308, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\operations\prepare.py", line 491, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\operations\prepare.py", line 577, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\operations\prepare.py", line 69, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\distributions\sdist.py", line 48, in prepare_distribution_metadata
    self._install_build_reqs(finder)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\distributions\sdist.py", line 118, in _install_build_reqs
    build_reqs = self._get_build_requires_wheel()
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\distributions\sdist.py", line 95, in _get_build_requires_wheel
    return backend.get_requires_for_build_wheel()
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_internal\utils\misc.py", line 685, in get_requires_for_build_wheel
    return super().get_requires_for_build_wheel(config_settings=cs)
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_vendor\pep517\wrappers.py", line 173, in get_requires_for_build_wheel
    return self._call_hook('get_requires_for_build_wheel', {
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_vendor\pep517\wrappers.py", line 319, in _call_hook
    raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
  File "C:\Users\kk\Downloads\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 77, in _build_backend
    obj = import_module(mod_path)
  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kk\AppData\Local\Temp\pip-build-env-wz_0zi4g\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module>
    import setuptools.version
  File "C:\Users\kk\AppData\Local\Temp\pip-build-env-wz_0zi4g\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module>
    import pkg_resources
  File "C:\Users\kk\AppData\Local\Temp\pip-build-env-wz_0zi4g\overlay\Lib\site-packages\pkg_resources\__init__.py", line 32, in <module>
    import plistlib
  File "plistlib.py", line 61, in <module>
  File "xml\parsers\expat.py", line 4, in <module>
ModuleNotFoundError: No module named 'pyexpat'

Code of Conduct

@bebound bebound added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Dec 21, 2022
@uranusjr
Copy link
Member

xml.parsers.expat is a standard library module, so this needs to be reported to https://github.com/python/cpython instead.

@uranusjr uranusjr closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2022
@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 Dec 21, 2022
@bebound
Copy link
Author

bebound commented Dec 21, 2022

@uranusjr But .\python.exe -c 'import xml.parsers.expat' works fine, I guess this related to pip?

@pfmoore
Copy link
Member

pfmoore commented Dec 21, 2022

The embeddable distribution of Python is not intended for general use as a Python interpreter. Can you reproduce this using a normal Python installation? And if so, can you trim down the issue to a test case that we can reproduce? If not, then the issue is likely something to do with your installation, and not a problem with pip.

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

Successfully merging a pull request may close this issue.

3 participants