Can't build wheel - error: invalid command 'bdist_wheel'

Captain Aporam picture Captain Aporam · May 4, 2016 · Viewed 15.2k times · Source

I've tried everything in this very related question: Why can I not create a wheel in python?

But I still get:

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'bdist_wheel'

Context:

$ pip --version
pip 8.1.1 from /home/bdillman/proj/fashion/lib/python3.5/site-packages (python 3.5)

$ python -c "import setuptools; print(setuptools.__version__)"
18.2

$ python --version
Python 3.5.1

$ which python
/home/bdillman/workspace/fashion/bin/python

$ pip list
Mako (1.0.4)
MarkupSafe (0.23)
peewee (2.8.0)
pip (8.1.1)
PyYAML (3.11)
setuptools (21.0.0)
wheel (0.29.0)

So it looks like everything is installed and the versions look good (I think). Anyone have ideas of things to check to further the diagnosis here?

The exact command is:

$ python setup.py bdist_wheel

I've also tried

$ sudo python setup.py bdist_wheel

I've also done pip install --upgrade setuptools and pip install --upgrade wheel, and they're up-to-date.

Answer

Two-Bit Alchemist picture Two-Bit Alchemist · Jul 1, 2018

I had this happen to me on a recent Ubuntu using python3 -m venv (for which you must install python3-venv), where no matter how many times I cleared the environment and retried, I was getting bdist_wheel errors installing the dependencies for Flask.

In addition to not having venv by default as normal for a Python 3 install, for some reason on Ubuntu I also seem to have to explicitly install wheel.

For clarity, the following did not work:

  1. python3 -m venv .
  2. . bin/activate
  3. pip install Flask

However, the following does work:

  1. python3 -m venv .
  2. . bin/activate
  3. pip install wheel (never had to do this on, say, Arch Linux)
  4. pip install Flask