Why can I not create a wheel in python?

2019-01-12 19:33发布

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.

8条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-12 20:01

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
查看更多
啃猪蹄的小仙女
3楼-- · 2019-01-12 20:02

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

查看更多
Animai°情兽
4楼-- · 2019-01-12 20:02

Update your setuptools, too.

pip install setuptools --upgrade

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

查看更多
不美不萌又怎样
5楼-- · 2019-01-12 20:03

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.

查看更多
唯我独甜
6楼-- · 2019-01-12 20:07

Update your pip first:

pip install --upgrade pip

for Python 3:

pip3 install --upgrade pip
查看更多
唯我独甜
7楼-- · 2019-01-12 20:11

Throwing in another answer: Try checking your PYTHONPATH.

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