为什么我不能在 python 中创建一个轮子?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26664102/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why can I not create a wheel in python?
提问by vitiral
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
另外,我正在运行带有自制 python 的 mac
Here is my setup.py script: https://gist.github.com/cloudformdesign/4791c46fe7cd52eb61cd
这是我的 setup.py 脚本:https: //gist.github.com/cloudformdesign/4791c46fe7cd52eb61cd
I'm going absolutely crazy -- I can't figure out why this wouldn't be working.
我快疯了——我不明白为什么这行不通。
采纳答案by Thomas Orozco
Install the wheelpackagefirst:
首先安装wheel软件包:
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...".
文档对此并不太清楚,但是“wheel 项目为 setuptools 提供了 bdist_wheel 命令”实际上意味着“wheel包......”。
回答by geographika
I also ran into the error message invalid command 'bdist_wheel'
我也遇到了错误信息 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.
事实证明,包 setup.py 使用的是 distutils 而不是 setuptools。如下更改它使我能够构建轮子。
#from distutils.core import setup
from setuptools import setup
回答by luckydonald
Update your setuptools, too.
也更新您的设置工具。
pip install setuptools --upgrade
If that fails too, you could try with additional --forceflag.
如果这也失败了,您可以尝试使用其他--force标志。
回答by jbg
I also ran into this all of a sudden, after it had previously worked, and it was because I was inside a virtualenv, and wheelwasn't installed in the virtualenv.
我也突然遇到了这个,在它之前工作之后,这是因为我在一个 virtualenv 中,并且wheel没有安装在 virtualenv 中。
回答by Aigrefin
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
我尝试了这里所说的一切,但没有任何运气,但找到了解决方法。运行此命令(并失败)后: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 .whlfile is in the distfolder.
转到工具创建的临时目录(在最后一个命令的输出中给出),然后执行python setup.py bdist_wheel. 该.whl文件在dist文件夹中。
回答by avidreader610
Throwing in another answer: Try checking your PYTHONPATH.
抛出另一个答案:尝试检查您的PYTHONPATH.
First, try to install wheelagain:
首先,wheel再次尝试安装:
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:
然后将轮子的位置添加到您的PYTHONPATH:
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.5/dist-packages/wheel
Now building a wheel should work fine.
现在构建一个轮子应该可以正常工作。
python setup.py bdist_wheel
回答by Bart Dorlandt
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.
也可能是您只有一个 python3 系统。因此,您已经通过 pip3 install 安装了必要的软件包,例如pip3 install wheel。
You'll need to build your stuff using python3 specifically.
你需要专门使用 python3 来构建你的东西。
python3 setup.py sdist
python3 setup.py bdist_wheel
Cheers.
干杯。
回答by Tombart
Update your pipfirst:
更新你的pip第一个:
pip install --upgrade pip
for Python 3:
对于 Python 3:
pip3 install --upgrade pip

