问题:为什么我不能在python中创建轮子?
这是我正在运行的命令:
$ 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
此外,我正在使用自制的python运行Mac
这是我的setup.py脚本:https :
//gist.github.com/cloudformdesign/4791c46fe7cd52eb61cd
我快要疯了-我不知道为什么这不起作用。
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.
回答 0
首先安装wheel
软件包:
pip install wheel
文档并不太清楚,但是“ wheel项目为setuptools提供了bdist_wheel命令”实际上是指“ wheel package …”。
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…”.
回答 1
我也遇到了错误信息 invalid command 'bdist_wheel'
原来包setup.py使用的是distutils而不是setuptools。如下进行更改可以使我制造轮子。
#from distutils.core import setup
from setuptools import setup
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
回答 2
也更新您的setuptools。
pip install setuptools --upgrade
如果仍然失败,则可以尝试使用其他--force
标志。
Update your setuptools, too.
pip install setuptools --upgrade
If that fails too, you could try with additional --force
flag.
回答 3
在以前无法正常工作之后,我也突然遇到了这种情况,这是因为我在virtualenv中,wheel
没有安装在virtualenv中。
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.
回答 4
更新您的pip
第一个:
pip install --upgrade pip
对于Python 3:
pip3 install --upgrade pip
Update your pip
first:
pip install --upgrade pip
for Python 3:
pip3 install --upgrade pip
回答 5
也可能是您只有python3系统。因此,您已经通过pip3 install安装了必要的软件包,例如pip3 install wheel。
您需要专门使用python3构建自己的东西。
python3 setup.py sdist
python3 setup.py bdist_wheel
干杯。
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.
回答 6
提出另一个答案:尝试检查您的PYTHONPATH
。
首先,尝试重新安装wheel
:
pip install wheel
这应该告诉您车轮安装在哪里,例如:
Requirement already satisfied: wheel in /usr/local/lib/python3.5/dist-packages
然后将wheel的位置添加到您的PYTHONPATH
:
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.5/dist-packages/wheel
现在,构建轮子应该可以正常工作。
python setup.py bdist_wheel
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
回答 7
我尝试了这里所说的一切,没有任何运气,但找到了解决方法。运行此命令后(失败):bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
转到工具制作的临时目录(在最后一个命令的输出中给出),然后执行python setup.py bdist_wheel
。该.whl
文件位于dist
文件夹中。
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.