如何在虚拟环境中使用requirements.txt和直接github源代码

vuktfyat  于 2023-02-14  发布在  Git
关注(0)|答案(1)|浏览(199)

有时候我必须使用github项目中的python模块,我可以在my_requirements. txt中这样做

git+https://github.com/zackhodari/tts_data_tools

我想使用python虚拟环境进行实验,因为我不想在我的机器上有很多垃圾。

pip install -r my_requirements.txt

这是一个很好的github项目的工作方法,有很好的requirements.txt。不幸的是,有很多其他项目与不一致的requirements.txt。这些项目需要一些模块预安装编译。
好的。我在我的my_requirements.txt中写了如下内容

numpy
git+https://github.com/zackhodari/tts_data_tools

并得到“模块numpy找不到”错误,因为PIP编译github项目不在我的虚拟环境中
我必须在我的环境编译github项目
这里是fulk错误消息

Collecting git+https://github.com/zackhodari/tts_data_tools (from -r requirements.txt (line 2))
  Cloning https://github.com/zackhodari/tts_data_tools to c:\users\XXX\appdata\local\temp\pip-req-build-4kv5zmyx
  Running command git clone --filter=blob:none --quiet https://github.com/zackhodari/tts_data_tools 'C:\Users\XXX\AppData\Local\Temp\pip-req-build-4kv5zmyx'
  Resolved https://github.com/zackhodari/tts_data_tools to commit 3c1aff21ab0fbed1bbfd2ba8a5a16d0eb610ffe1
  Preparing metadata (setup.py) ... done
Collecting numpy
  Using cached numpy-1.24.2-cp38-cp38-win_amd64.whl (14.9 MB)
Collecting pyreaper
  Using cached pyreaper-0.0.8.tar.gz (124 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\XXX\AppData\Local\Temp\pip-install-_4t7gi1p\pyreaper_27e0fd80dcb141b98b17dd963414e84f\setup.py", line 8, in <module>
          import numpy as np
      ModuleNotFoundError: No module named '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.

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

r1zk6ea11#

这是pyreaper中的一个错误:它在安装之前导入numpy。所以你需要先安装numpy
不幸的是,这不能通过my_requirements.txt来完成。如果你添加了numpypip会下载并解压缩numpy,但并没有完全安装它,因此其他需要numpy的软件包在整个my_requirements.txt处理完成之前还不能导入它。在my_requirements.txt中安装任何需要任何其他尚未安装的软件包的软件包将失败。
你可以先完全安装numpy,然后再安装所有需要它的软件包,或者你可以先安装report the bug,等到它被修复,然后再安装任何软件包,而不预先安装numpy

相关问题