即使安装了模块,Python ModuleNotFound 错误

问题描述 投票:0回答:1

添加Python3虚拟环境 -

python3 -m venv .venv

进入这个虚拟环境 -

source .venv/bin/activate

添加模块 numpy -

python3 -m pip install numpy

然后尝试添加模块圈 -

python3 -m pip install lap
。 此命令会产生错误 -
ModuleNotFoundError: No module named 'numpy'
和下面几行 -
ImportError: lap requires numpy, please "pip install numpy"

什么???

更新

另一个虚拟环境的使用:

vbulash@vbulash-notebook:~/VSCode/recognition$ python3 -m venv .venv2
vbulash@vbulash-notebook:~/VSCode/recognition$ source .venv2/bin/activate
(.venv2) vbulash@vbulash-notebook:~/VSCode/recognition$ python3 -m pip install lap
Collecting lap
  Using cached lap-0.4.0.tar.gz (1.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      <string>:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      Partial import of lap during the build process.
      Traceback (most recent call last):
        File "<string>", line 127, in get_numpy_status
      ModuleNotFoundError: No module named 'numpy'
      Traceback (most recent call last):
        File "/home/vbulash/VSCode/recognition/.venv2/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/vbulash/VSCode/recognition/.venv2/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/vbulash/VSCode/recognition/.venv2/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-1zmi7bid/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 366, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/tmp/pip-build-env-1zmi7bid/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-1zmi7bid/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 236, in <module>
        File "<string>", line 220, in setup_package
      ImportError: lap requires numpy, please "pip install numpy".
      [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.

python-3.x numpy pip
1个回答
0
投票

该错误已被报告多次。仍然没有解决。最后一个版本

lap
0.4.0 于 2018 年发布。最后一次提交是在 2022 年。该软件包似乎已经过时、有缺陷并且已被废弃。

有一个建议安装

lapx
,这是一个固定的插入式叉子。所以尝试一下吧

pip install lapx
© www.soinside.com 2019 - 2024. All rights reserved.