python - 从requirements.txt中安装轮子

标签 python python-3.x pip python-wheel python-venv

我正在尝试配置我的 requirements.txt,如下所示:

wheel
apache-airflow

我创建了python3.8 -m venv ~/test-env并尝试进行安装。问题是

python -m pip install -r requirements.txt

产生大量消息

error: invalid command 'bdist_wheel'                                                                                                                                                                                            

----------------------------------------                                                                                                                                                                                        
Failed building wheel for thrift        

我确保在安装 requirements.txt 时安装了 wheel:

Collecting wheel (from -r requirements.txt (line 1))                                                                                                                                                                              
Using cached https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.

但是如果我单独安装

python -m pip install wheel
python -m pip install -r requirements

它工作正常,python -m pip -r requests 完成时没有错误消息。

那么是否可以将wheel安装放入requirements.txt中?安装到 venv 时处理它的正确方法是什么?要在安装 requirements.txt 之前安装它?

最佳答案

我相信旧版本的 pip 会发生这种情况。例如,在我的快速测试中,pip 9.0.1 就发生了这种情况,默认情况下,它是通过 Python 3.6ensurepip 标准库提供的,但它并没有一旦pip更新到19.2.3,据我所知应该与Python 3.8捆绑在一起。您似乎使用的是 Python 3.8,所以我对您遇到此错误的事实感到困惑。无论如何,这个错误不应有效地阻止需求的实际安装。

如果可能的话,我建议更新 pip:

python -m pip install --upgrade pip

安装要求之前:

python -m pip install --requirement requests.txt

在这种情况下,从需求文件中安装wheel(或更新pip)是没有用的。

关于python - 从requirements.txt中安装轮子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59104686/

相关文章:

python - 由于 pip 安装错误,无法在 python 2.7.5 中创建 virtualenv 实例

python - 在图像上绘制真实的实心圆

python - 从另一个文件导入类

python - LCARS GUI 从哪里开始

python - 在 getopt 命令中查找多个参数 Python 3

python - 如何从两个列表(其中一个是嵌套的)创建字典?

python - 无法升级 Pip。没有权限。为什么?

python - "ImportError: No module named requests;"在终端中工作,而不在 Visual Studio 中工作

Python将int添加到日期中并且仅返回工作日日期而忽略周末

python - 如何用 pandas 为空行着色并导出到 Excel 文件?