为Python3 - python3 -m venv .venv添加虚拟环境.

进入此虚拟环境- source .venv/bin/activate.

添加模块numpy - python3 -m pip install numpy.

然后try 添加模块lap - python3 -m pip install lap. 此命令会产生错误-ModuleNotFoundError: No module named 'numpy'和-ImportError: lap requires numpy, please "pip install numpy"以下的几行.

什么??

UPDATE

另一个虚拟环境的使用:

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.

推荐答案

该错误有reported多次.仍然没有解决方案.最新版本lap 0.4.0于2018年发布.Last commit是在2022年.该包裹似乎过时、充满缺陷且被废弃.

There is an advice安装lapx,这是一个固定的插入式fork .所以尽量

pip install lapx

Python-3.x相关问答推荐

是否可以使用参数对Flask重定向?

Pandas 根据条件增加Dataframe列

在 sum() 中将字符串转换为 int (或 float)

替换 .txt 文件中的项目列表

Python中根据分组/ID对两个数据框进行映射,以更接近值的升序排列

获取字符串中的两个工作日之间的差异

当我判断另一个 checkButton 时,如何判断两个 python tkinter checkButtons?

如何使用pandas python获取数据框中每列的最大长度

Generic[T] 基类 - 如何从实例中获取 T 的类型?

Tkinter AttributeError:对象没有属性'tk'

Jupyter Notebook - 在函数内绘图 - 未绘制图形

Pylint 给我最后的新行丢失

pip install dryscrape 失败并显示错误:[Errno 2] 没有这样的文件或目录:'src/webkit_server'?

在计算之前删除包含某些值的组合

为什么在 Python 中不推荐使用 MutableString?

用 numpy nan 查找列表的最大值

SQLAlchemy:如果不存在则创建模式

带有数千个逗号刻度标签的 MatPlotLib 美元符号

Python 3中星型导入的函数形式是什么

有没有办法在多个线程中使用 asyncio.Queue ?