Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 693
Captain Aporam Avatar asked May 04 '16 13:05

Captain Aporam


People also ask

What is setup py bdist_wheel?

python setup.py bdist_wheel. This will build any C extensions in the project and then package those and the pure Python code into a . whl file in the dist directory.

Is setup py deprecated?

With the latest version of setuptools, the python setup.py install command is being deprecated (see https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for more info).

How do I run a setup py file?

To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.


Video Answer


2 Answers

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
like image 129
Two-Bit Alchemist Avatar answered Oct 24 '22 18:10

Two-Bit Alchemist


Solved it. I'm not sure how, but my python virtual environment was messed up, with pip using a different virtual environment. I fixed my virtual environment and now everything seems to work fine.

I'm new to python and virtual environments, and I think I might've copied a whole project containing a virtual environment, then edited it (and missed some references, say at the top of the pip script).

like image 33
Captain Aporam Avatar answered Oct 24 '22 20:10

Captain Aporam