20

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.

Community
  • 1
  • 1
Captain Aporam
  • 315
  • 1
  • 4
  • 13
  • What is the exact command you're using to build the wheel file? – linusg May 04 '16 at 13:33
  • 1
    Ah, and maybe updating pip, wheel and setuptools (`pip install --upgrade setuptools` ect.)! – linusg May 04 '16 at 13:37
  • Added the info to the question. I tried all the things listed in the linked question, but no success. It must be something else. – Captain Aporam May 04 '16 at 14:27
  • Check the python path which is executed when you run it from sudo, since you are using a local install for python. Most likely you are using different versions when running with/without sudo. – João Pinto May 04 '16 at 14:53
  • When I run from sudo I do get another python (/usr/bin/python) but I did a `su root` and `source ./bin/activate`. No success, everything still as above. – Captain Aporam May 04 '16 at 15:03
  • `pip install --upgrade setuptools` solved the problem for me. – qed Apr 25 '17 at 10:37
  • Does this answer your question? [Why can I not create a wheel in python?](https://stackoverflow.com/questions/26664102/why-can-i-not-create-a-wheel-in-python) – betontalpfa Nov 16 '20 at 09:47

5 Answers5

33

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
Two-Bit Alchemist
  • 17,966
  • 6
  • 47
  • 82
3

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).

Captain Aporam
  • 315
  • 1
  • 4
  • 13
3

You should always install wheel first after setting up a virtual environment. I usually do it right away after activation of venv in order to not forget about it and mess things up in case some of the packages have no other default means of installation other than through wheel (as far as I know wheel is involved in installation of pip packages)

Install virtualenv and pip in the global directory,create your environment, activate it and install wheel. $ python3 -m pip install wheel After that you do you.

0

One thing to note is that make sure you are using setuptools, not distutils.

HVNSweeting
  • 2,859
  • 2
  • 35
  • 30
0

As @HVNSweeting mentioned I found out that I had distutils in my setup.py file. In my case I could just change the from in my setup.py file to use the bdist_wheel.

# remove this line
from distutils.core import setup
# insert this line
from setuptools import setup
deckerch
  • 197
  • 1
  • 8