如何以轮格式安装 Python 库? [英] How do I install Python libraries in wheel format?
问题描述
我正在寻找有关如何以轮格式安装 Python 库的教程.
这看起来并不简单,所以我很欣赏一个简单的分步教程,如何为 CPython 安装名为requests"的模块.
我从:https://pypi.python.org/pypi/requests 下载了它,现在我有一个.whl 文件.我在 Windows 上安装了 Python 2.7 和 3.3,那么如何安装它以便我运行的所有其他 Python 脚本都可以使用它?
您想在 Windows 下的 Python 上安装下载的轮子 (.whl) 文件?
- 在 Windows 上的 Python 上安装 pip(在 Python 上3.4+ 已经包含)
必要时升级 pip(在命令行上)
pip install -U pip
使用pip(在命令行上)安装本地wheel文件
pip install --no-index --find-links=LocalPathToWheelFile PackageName
Option --no-index
告诉 pip 不要查看 pypi.python.org(如果你没有安装编译器,很多包都会失败),--find-links
然后告诉 pip 去哪里寻找.PackageName
是包的名称(numpy、scipy、..wheel 文件名的第一部分或全部).有关详细信息,请参阅 pip 的安装选项.>
切换到 Python 安装的 Scripts
文件夹时,您可以在命令提示符中执行这些命令.
示例:
cd C:Python27Scriptspip 安装 -U pippip install --no-index --find-links=LocalPathToWheelFile PackageName
注意:该包仍然可能没有安装在 Windows 上,因为它可能包含需要编译的 C/C++ 源文件.然后你需要 确保编译器已安装.通常搜索替代预编译发行版是最快的出路.>
例如 numpy-1.9.2+mkl-cp27-none-win_amd64.whl
有 PackageName
numpy
.
I was looking for a tutorial on how to install Python libraries in the wheel format.
It does not seem straightforward so I'd appreciate a simple step by step tutorial how to install the module named "requests" for CPython.
I downloaded it from: https://pypi.python.org/pypi/requests and now I have a .whl file. I've got Python 2.7 and 3.3 on Windows, so how do I install it so all the other Python scripts I run can use it?
You want to install a downloaded wheel (.whl) file on Python under Windows?
- Install pip on your Python(s) on Windows (on Python 3.4+ it is already included)
Upgrade pip if necessary (on the command line)
pip install -U pip
Install a local wheel file using pip (on the command line)
pip install --no-index --find-links=LocalPathToWheelFile PackageName
Option --no-index
tells pip to not look on pypi.python.org (which would fail for many packages if you have no compiler installed), --find-links
then tells pip where to look for instead. PackageName
is the name of the package (numpy, scipy, .. first part or whole of wheel file name). For more informations see the install options of pip.
You can execute these commands in the command prompt when switching to your Scripts
folder of your Python installation.
Example:
cd C:Python27Scripts
pip install -U pip
pip install --no-index --find-links=LocalPathToWheelFile PackageName
Note: It can still be that the package does not install on Windows because it may contain C/C++ source files which need to be compiled. You would need then to make sure a compiler is installed. Often searching for alternative pre-compiled distributions is the fastest way out.
For example numpy-1.9.2+mkl-cp27-none-win_amd64.whl
has PackageName
numpy
.
这篇关于如何以轮格式安装 Python 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!