How can I install lmdb module for python

955 views Asked by At

I want to download the python lmdb module, but I constantly encounter this problem. Patch-ng module is installed. I also tried Python version 3.12 on older versions.

\`C:\\Users\\WIN10\>pip install lmdb
Collecting lmdb
Using cached lmdb-1.4.1.tar.gz (881 kB)
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
╰─\> \[27 lines of output\]
py-lmdb: Using bundled liblmdb with py-lmdb patches; override with LMDB_FORCE_SYSTEM=1 or LMDB_PURE=1.
Traceback (most recent call last):
File "\<string\>", line 92, in \<module\>
ModuleNotFoundError: No module named 'patch_ng'

      During handling of the above exception, another exception occurred:
    
      Traceback (most recent call last):
        File "C:\Users\WIN10\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\WIN10\AppData\Local\Programs\Python\Python312\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 "C:\Users\WIN10\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\WIN10\AppData\Local\Temp\pip-build-env-5jq1lpwf\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\WIN10\AppData\Local\Temp\pip-build-env-5jq1lpwf\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "C:\Users\WIN10\AppData\Local\Temp\pip-build-env-5jq1lpwf\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "C:\Users\WIN10\AppData\Local\Temp\pip-build-env-5jq1lpwf\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 94, in <module>
      Exception: Building py-lmdb from source on Windows requires the "patch-ng" python module.
      [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.\

I tried to install the package and I'm getting an error.

2

There are 2 answers

4
Vinayak Bhandari On

We can install lmdb module using 'pip' package manager:

pip install lmdb

After the installation you should be able to import the module in your python scripts or projects:

import lmdb
0
zsynacl On

It seems that lmdb only supports python 3.11 or lower.

So the best try is to downgrade your python to 3.11 or 3.10.

Reference: https://github.com/PaddlePaddle/PaddleOCR/issues/11516