195

Here are the commands I am running:

$ python setup.py bdist_wheel
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'

$ pip --version
pip 1.5.6 from /usr/local/lib/python3.4/site-packages (python 3.4)

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

$ python --version
Python 3.4.1

$ which python
/usr/local/bin/python

Also, I am running a mac with homebrewed python

Here is my setup.py script: https://gist.github.com/cloudformdesign/4791c46fe7cd52eb61cd

I'm going absolutely crazy -- I can't figure out why this wouldn't be working.

2
  • 2
    And you have installed the wheel package as Thomas' answer advises? Commented Oct 30, 2014 at 22:10
  • 1
    I have the same problem. But it seems that i didn't use sudo before the commend. After use the commend with administrate permission. it worked. Commented Jan 21, 2016 at 2:49

8 Answers 8

312

Install the wheel package first:

pip install wheel

The documentation isn't overly clear on this, but "the wheel project provides a bdist_wheel command for setuptools" actually means "the wheel package...".

Sign up to request clarification or add additional context in comments.

8 Comments

So that spit out the file: nioblocks-1.01-cp34-cp34m-macosx_10_9_x86_64.whl -- will this work with any OS, or is there something else I have to do to get it to work? (the "package" is just a bunch of dependencies for pip to install right now)
@GarrettLinux I wouldn't know, I'm sorry, but I'd encourage you to ask a separate question for that ; )
I fixed that problem too -- adding any file to the setup.py file gave it a general wheel. Check out the updated code in my question for example.
You can get the OP's error even with wheel installed, if the setup.py somehow uses distutils instead of setuptools (as was case for me), see the answer by geographika.
For me the problem was old version of pip. fixed by pip install --upgrade pip
|
171

I also ran into the error message invalid command 'bdist_wheel'

It turns out the package setup.py used distutils rather than setuptools. Changing it as follows enabled me to build the wheel.

#from distutils.core import setup
from setuptools import setup

4 Comments

yup, I had that problem at one time as well! Very important, and the error message is poor.
@geographika yes this is command also the documentation on docs.python.org/2/distutils/setupscript.html would replicate the issues you are seeig as it uses disutils
May also be necessary to change from distutils.core import Extension, Command to from setuptools import Extension, Command at least for package I was working with.
I got this error for pycrypto and it wasn't even importing setup. However, I added from setuptools import setup at the beginning and it fixed the issue.
40

Update your setuptools, too.

pip install setuptools --upgrade

If that fails too, you could try with additional --force flag.

1 Comment

my setuptools was removed, or something was wrong. So I had to do : pip install setuptools --upgrade --force
15

I also ran into this all of a sudden, after it had previously worked, and it was because I was inside a virtualenv, and wheel wasn’t installed in the virtualenv.

Comments

11

Update your pip first:

pip install --upgrade pip

for Python 3:

pip3 install --upgrade pip

1 Comment

This is the most useful answer now. Newer versions of pip install don't use bdist_wheel, so just upgrading pip worked for me, without needing to install/update setuptools or wheel
5

Throwing in another answer: Try checking your PYTHONPATH.

First, try to install wheel again:

pip install wheel

This should tell you where wheel is installed, eg:

Requirement already satisfied: wheel in /usr/local/lib/python3.5/dist-packages

Then add the location of wheel to your PYTHONPATH:

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.5/dist-packages/wheel

Now building a wheel should work fine.

python setup.py bdist_wheel

Comments

4

It could also be that you have a python3 system only. You therefore have installed the necessary packages via pip3 install , like pip3 install wheel.

You'll need to build your stuff using python3 specifically.

python3 setup.py sdist
python3 setup.py bdist_wheel

Cheers.

Comments

2

I tried everything said here without any luck, but found a workaround. After running this command (and failing) : bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

Go to the temporary directory the tool made (given in the output of the last command), then execute python setup.py bdist_wheel. The .whl file is in the dist folder.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.