如何以轮式格式安装Python库? [英] How do I install Python libraries in wheel format?

查看:341
本文介绍了如何以轮式格式安装Python库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找有关如何以wheel格式安装Python库的教程.

这似乎并不简单,所以我将对如何安装CPython名为"requests"的模块的简单分步教程有所帮助.

我从以下位置下载了它: https://pypi.python.org/pypi/requests 现在,我有一个.whl文件.我在Windows上安装了Python 2.7和3.3,那么如何安装它,以便我运行的所有其他Python脚本都可以使用它?

解决方案

您想在Windows下的Python上安装下载的wheel(.whl)文件吗?

  1. 在Windows上的Python上安装pip (在Python上3.4+已包含在内)
  2. 如有必要(在命令行上)升级点

    pip install -U pip
    

  3. 使用pip(在命令行上)安装本地wheel文件

    pip install --no-index --find-links=LocalPathToWheelFile PackageName
    

选项--no-index告诉pip不要在pypi.python.org上查找(如果没有安装编译器,许多软件包将失败),然后--find-links告诉pip到哪里查找. PackageName是程序包的名称(numpy,scipy,.. wheel文件名的第一部分或全部).有关更多信息,请参见pip的安装选项.

>

切换到Python安装的Scripts文件夹时,可以在命令提示符下执行这些命令.

示例:

cd C:\Python27\Scripts
pip install -U pip
pip 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?

  1. Install pip on your Python(s) on Windows (on Python 3.4+ it is already included)
  2. Upgrade pip if necessary (on the command line)

    pip install -U pip
    

  3. 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:\Python27\Scripts
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆