markitdown icon indicating copy to clipboard operation
markitdown copied to clipboard

Unable to install package "ModuleNotFoundError: No module named 'packaging.licenses'"

Open AdamSharif-MSFT opened this issue 10 months ago • 4 comments

I'm running Ubuntu 22.04.5 LTS on WSL, when trying to execute pip install -e packages/markitdown I receive the following error:

Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/adamsharif/repos/markitdown/packages/markitdown
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Installing backend dependencies ... done
  Preparing editable metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing editable metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 191, in prepare_metadata_for_build_editable
          return hook(metadata_directory, config_settings)
        File "/tmp/pip-build-env-hmk0ad27/overlay/local/lib/python3.10/dist-packages/hatchling/build.py", line 142, in prepare_metadata_for_build_editable
          f.write(builder.config.core_metadata_constructor(builder.metadata, extra_dependencies=extra_dependencies))
        File "/tmp/pip-build-env-hmk0ad27/overlay/local/lib/python3.10/dist-packages/hatchling/metadata/spec.py", line 546, in construct_metadata_file_2_4
          if metadata.core.license:
        File "/tmp/pip-build-env-hmk0ad27/overlay/local/lib/python3.10/dist-packages/hatchling/metadata/core.py", line 677, in license
          from packaging.licenses import canonicalize_license_expression
      ModuleNotFoundError: No module named 'packaging.licenses'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

It's a fresh clone of the repo and I have full access to the cloned directory - running version pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

Already tried pip cache purge and a re-run but no change.

Does anyone know how I can resolve this please?

AdamSharif-MSFT avatar Feb 21 '25 16:02 AdamSharif-MSFT

Hmmm. Thanks for the report. I wonder if it's a 3.10 issue. I will investigate asap.

afourney avatar Feb 28 '25 07:02 afourney

bro i tried using the following docker file Use

Ubuntu 22.04 as the base image
FROM ubuntu:22.04
RUN apt update && apt install -y \
    python3.10 \
    python3-pip \
    git \
    && apt clean

RUN python3.10 -m pip install pip==22.0.2

WORKDIR /app

RUN git clone https://github.com/microsoft/markitdown.git
WORKDIR /app/markitdown/packages/markitdown

RUN python3.10 -m pip install -e .

and can successfully able to build I think something like apt upgrade or pip upgrade will solve the problem

SigireddyBalasai avatar Feb 28 '25 18:02 SigireddyBalasai

I encountered the same error with Python 3.10. Then I upgraded to Python 3.11 and the error went away.

markusdr avatar Mar 26 '25 23:03 markusdr

I encountered the same error with Python 3.10. Then I upgraded to Python 3.11 and the error went away.

Thanks for the report. I'll try to reproduce the error with information and fix it.

Edit: I think something like this might be the root of the problem https://github.com/pypa/setuptools/issues/4894 (though this is perhaps a newer instance of the same problem....)

Could you try updating the packages module as recommended? Or report what version of setuptools and packaging you have?

Unfortunately, I have not been able to reproduce this in several 3.10 environments.. so testing potential fixes has been challenging.

afourney avatar Mar 27 '25 13:03 afourney