Can't build wheel - error: invalid command 

2019-04-21 15:52发布

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.

3条回答
迷人小祖宗
2楼-- · 2019-04-21 16:15

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

查看更多
做个烂人
3楼-- · 2019-04-21 16:21

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

查看更多
【Aperson】
4楼-- · 2019-04-21 16:22

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
查看更多
登录 后发表回答