8

I'm trying to configure my requirements.txt which is the following:

wheel
apache-airflow

I created python3.8 -m venv ~/test-env and tried to do the installation. The problem is

python -m pip install -r requirements.txt

produces tons of messages

error: invalid command 'bdist_wheel'                                                                                                                                                                                            

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

I made sure that wheel is installed when doing requirements.txt installation:

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.

But if I install it separately

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

it works fine and the python -m pip -r requirements finishes with no error messages.

So isn't it possible to put wheel installation into requirements.txt? What is the proper way to deal with it when installing into venv? To install it before requirements.txt installation?

St.Antario
  • 26,175
  • 41
  • 130
  • 318
  • If you look at the `wheel` package you'll see this: "This library is the reference implementation of the Python wheel packaging standard, as defined in PEP 427." Theres no real point in installing it. – SitiSchu Nov 29 '19 at 12:23
  • @SitiSchu In the official documentation guide it was mentioned to make sure the latest version `setuptools` and `wheel` via `pip`. https://packaging.python.org/tutorials/packaging-projects/#generating-distribution-archives – St.Antario Nov 29 '19 at 12:30
  • 1
    Thats the documentation for packaging a project, not installing a package. – SitiSchu Nov 29 '19 at 12:31
  • @SitiSchu Without installing `wheel` package `bdist_wheel` command is not available for `setup.py`. That's exactly what I saw in the error messages. Why did you say that it was pointless? – St.Antario Nov 29 '19 at 12:33
  • As explained in the link you shared it's a requirement when building your own distribution package to upload them on pypi, not a requirment when installing your package elsewhere (i.e. no point to include it in requirements.txt) – buran Nov 29 '19 at 12:44
  • @buran So how to explain this error message when installing from `venv` (installing in the core python installation works fine)? – St.Antario Nov 29 '19 at 12:47
  • Do you get a error when you run `python -m pip install apache-airflow` ? – SitiSchu Nov 29 '19 at 12:48
  • @SitiSchu Yes, but only when installing into my own `venv` that I created specifically for that. Installation into the core system python works fine. – St.Antario Nov 29 '19 at 12:52
  • What is the version of _pip_ that is installed in your virtual environment? – sinoroc Dec 02 '19 at 09:38

1 Answers1

5

I believe this happens with older versions of pip. For example in my quick tests it happens with pip 9.0.1 which is delivered by default with Python 3.6's ensurepip standard library, but doesn't happen once pip is updated to 19.2.3 which as far as I know should be bundled with Python 3.8. You seem to be using Python 3.8 so I'm confused by the fact that you encounter this error. Anyway this error, shouldn't effectively block the actual installation of the requirements.

If possible I'd recommend updating pip:

python -m pip install --upgrade pip

before installing the requirements:

python -m pip install --requirement requirements.txt

Installing wheel (or updating pip) from within the requirements file is not useful in this case.

sinoroc
  • 18,409
  • 2
  • 39
  • 70
  • What about when you have a package that requires a wheel be built during installation? If wheel is gathered and the package installed before wheel it doesn't work. – ingyhere Jun 05 '21 at 00:45
  • @ingyhere I do not understand what you mean. -- This is a rather old Q&A. Things have changed since then. – sinoroc Jun 05 '21 at 08:21
  • I mean exactly that you cannot install wheel to be used for something else within the same requirements file. It doesn't work in version 21.1.x (latest as of this writing). Pip must install wheel separately, in advance, of installing the requirements file. [Here's a kludgy workaround](https://stackoverflow.com/a/29202283/325452). Since this question is from 2019 I consider it relatively new as of 2021. – ingyhere Jun 05 '21 at 20:07
  • My guess, you probably want to disable pip's "build isolation". Look it up and see if that helps your use case. – sinoroc Jun 05 '21 at 21:42