I was looking for a tutorial on how to install Python libraries in the wheel format.
我正在寻找有关如何以轮式格式安装Python库的教程。
It does not seem straightforward so I'd appreciate a simple step by step tutorial how to install the module named "requests" for CPython.
它似乎并不简单,所以我很欣赏一个简单的一步一步教程如何为CPython安装名为“requests”的模块。
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?
我从以下网址下载:https://pypi.python.org/pypi/requests现在我有一个.whl文件。我在Windows上有Python 2.7和3.3,所以如何安装它以便我运行的所有其他Python脚本都可以使用它?
10 个解决方案
#1
19
You want to install a downloaded wheel (.whl) file on Python under Windows?
您想在Windows下在Python上安装下载的wheel(.whl)文件吗?
- 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(在命令行上)
pip install -U pip
-
Install a local wheel file using pip (on the command line)
使用pip安装本地wheel文件(在命令行上)
pip install --no-index --find-links=LocalPathToWheelFile PackageName
在Windows上的Python上安装pip(在Python 3.4+上已经包含它)
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.
选项--no-index告诉pip不要查看pypi.python.org(如果没有安装编译器,许多软件包会失败), - find-links然后告诉pip在哪里寻找。 PackageName是包的名称(numpy,scipy,..第一部分或整个轮文件名)。有关更多信息,请参阅pip的安装选项。
You can execute these commands in the command prompt when switching to your Scripts
folder of your Python installation.
切换到Python安装的Scripts文件夹时,可以在命令提示符中执行这些命令。
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.
注意:它可能仍然是因为它可能包含需要编译的C / C ++源文件而无法在Windows上安装。然后,您需要确保安装了编译器。经常搜索备选的预编译分发是最快的出路。
For example numpy-1.9.2+mkl-cp27-none-win_amd64.whl
has PackageName
numpy
.
例如numpy-1.9.2 + mkl-cp27-none-win_amd64.whl具有PackageName numpy。
#2
8
If you want to be relax for installing libraries for python.
如果你想放松安装python库。
You should using pip
, that is python installer package.
你应该使用pip,即python安装包。
To install pip:
要安装pip:
-
Download ez_setup.py and then run:
下载ez_setup.py,然后运行:
python ez_setup.py
-
Then download get-pip.py and run:
然后下载get-pip.py并运行:
python get-pip.py
-
upgrade installed
setuptools
by pip:通过pip升级安装的setuptools:
pip install setuptools --upgrade
If you got this error:
如果您收到此错误:
Wheel installs require setuptools >= 0.8 for dist-info support. pip's wheel support requires setuptools >= 0.8 for dist-info support.
Add
--no-use-wheel
to above cmd:将--no-use-wheel添加到cmd以上:
pip install setuptools --no-use-wheel --upgrade
Now, you can install libraries for python, just by:
现在,您可以为python安装库,只需:
pip install library_name
For example:
pip install requests
Note that to install some library may they need to compile, so you need to have compiler.
注意,安装某些库可能需要编译,因此需要编译器。
On windows there is a site for Unofficial Windows Binaries for Python Extension Packages that have huge python packages and complied python packages for windows.
在Windows上有一个用于Python扩展包的非官方Windows二进制文件的站点,它具有巨大的python包和用于Windows的编译python包。
For example to install pip
using this site, just download and install setuptools and pip installer from that.
例如,要使用此站点安装pip,只需从中下载并安装setuptools和pip安装程序。
#3
2
To install wheel packages in python 2.7x:
在python 2.7x中安装wheel包:
-
Install python 2.7x (i would recommend python 2.78) - download the appropriate python binary for your version of windows . You can download python 2.78 at this site https://www.python.org/download/releases/2.7.8/ -I would recommend installing the graphical Tk module, and including python 2.78 in the windows path (environment variables) during installation.
安装python 2.7x(我建议使用python 2.78) - 为你的windows版本下载相应的python二进制文件。您可以在此站点下载python 2.78 https://www.python.org/download/releases/2.7.8/ - 我建议安装图形Tk模块,并在安装过程中在Windows路径(环境变量)中包含python 2.78 。
-
Install get-pip.py and setuptools Download the installer at https://bootstrap.pypa.io/get-pip.py Double click the above file to run it. It will install pip and setuptools [or update them, if you have an earlier version of either]
安装get-pip.py和setuptools在https://bootstrap.pypa.io/get-pip.py下载安装程序双击上面的文件运行它。它将安装pip和setuptools [或更新它们,如果你有任何一个的早期版本]
-Double click the above file and wait - it will open a black window and print will scroll across the screen as it downloads and installs [or updates] pip and setuptools --->when it finishes the window will close.
- 双击上面的文件并等待 - 它将打开一个黑色的窗口,打印将在屏幕上滚动,因为它下载并安装[或更新] pip和setuptools --->当它完成时窗口将关闭。
- Open an elevated command prompt - click on windows start icon, enter cmd in the search field (but do not press enter), then press ctrl+shift+. Click 'yes' when the uac box appears.
打开提升的命令提示符 - 单击Windows开始图标,在搜索字段中输入cmd(但不要按回车键),然后按ctrl + shift +。出现uac框时单击“是”。
A-type cd c:\python27\scripts [or cd \scripts ]
A-type cd c:\ python27 \ scripts [或cd \ scripts]
B-type pip install -u Eg to install pyside, type pip install -u pyside
B型pip安装-u例如安装pyside,输入pip install -u pyside
Wait - it will state 'downloading PySide or -->it will download and install the appropriate version of the python package [the one that corresponds to your version of python and windows.]
等待 - 它将声明'下载PySide或 - >它将下载并安装相应版本的python包[与您的python和windows版本对应的版本]。
Note - if you have downloaded the .whl file and saved it locally on your hard drive, type in
pip install --no-index --find-links=localpathtowheelfile packagename
注意 - 如果您已下载.whl文件并将其本地保存在硬盘驱动器上,请键入pip install --no-index --find-links = localpathtowheelfile packagename
**to install a previously downloaded wheel package you need to type in the following command pip install --no-index --find-links=localpathtowheelfile packagename
**要安装以前下载的wheel包,你需要输入以下命令pip install --no-index --find-links = localpathtowheelfile packagename
#4
1
Have you checked this http://docs.python.org/2/install/ ?
你检查过这个http://docs.python.org/2/install/吗?
-
First you have to install the module
首先,您必须安装该模块
$ pip install requests
$ pip安装请求
-
Then, before using it you must import it from your program.
然后,在使用它之前,您必须从程序中导入它。
from requests import requests
来自请求导入请求
Note that your modules must be in the same directory.
请注意,您的模块必须位于同一目录中。
-
Then you can use it.
然后你可以使用它。
For this part you have to check for the documentation.
对于这部分,您必须检查文档。
#5
0
Install distribute by downloading and running distribute_setup.py. This will make easy_install available, and from there you can install pip with easy_install pip. Then you can run pip install CAGE. Using pip to install things is a lot easier than messing with manually running setup.py, because pip can do things like:
通过下载并运行distribute_setup.py来安装分发。这将使easy_install可用,并从那里你可以使用easy_install pip安装pip。然后你可以运行pip install CAGE。使用pip来安装东西要比乱用手动运行setup.py容易得多,因为pip可以执行以下操作:
automatically resolve dependencies
show you a list of all installed packages and their versions
install a set of specified packages from a requirements.txt
upgrade and uninstall packages
work with virtualenv
If you're on Windows, the one downside of pip occurs when there are C library dependencies, as pip will want a C toolchain installed so it can compile things. If that is the case, then there are two options. If there are precompiled binaries on PyPI, then just run easy_install package instead; easy_install knows how to use binary packages. You can also check Christoph Gohlke's site for executable installers of many binary packages. These can also be installed by easy_install if you want to use them with a virtualenv (just point it to the path of the .exe) or you can click and run if you don't care about virtualenv.
如果您使用的是Windows,那么当存在C库依赖项时,pip会出现一个缺点,因为pip需要安装C工具链才能编译。如果是这种情况,那么有两种选择。如果PyPI上有预编译的二进制文件,那么只需运行easy_install包; easy_install知道如何使用二进制包。您还可以查看Christoph Gohlke的网站,了解许多二进制包的可执行安装程序。如果你想将它们与virtualenv一起使用(只需将它指向.exe的路径),也可以通过easy_install安装它们,或者如果你不关心virtualenv,你可以点击并运行。
The main point is that no matter what route you choose to install packages, at no point are you ever moving around files by hand. You need to get out of the mindset of "I extracted this archive, where do I put these .py files?" That's not how it works. You're either running pip, running easy_install, running setup.py, clicking on an installer package, or using your distribution's installer. At no point are you ever doing anything by hand with the files directly.
重点是,无论您选择安装包的路线是什么,您都不会手动移动文件。你需要摆脱“我提取这个档案,我在哪里放这些.py文件?”的心态。这不是它的工作原理。您要么运行pip,运行easy_install,运行setup.py,单击安装程序包,要么使用分发的安装程序。在任何时候你都没有直接手工处理文件。
#6
0
Once you have a library downloaded you can execute this from the MS-DOS command box:
下载库后,可以从MS-DOS命令框执行此操作:
python setup.py install
The setup.py
is located inside every library main folder.
setup.py位于每个库主文件夹中。
#7
0
For windows, there are automatic installer packages available at this site
对于Windows,此站点提供自动安装程序包
It includes most of the python packages.
它包括大多数python包。
But the best way for it is of course using pip.
但最好的方法当然是使用pip。
#8
0
You don't need to download exclusively from the website. Just make sure you have pip (which you probably will if you have python installed). Just open your Command Prompt (CMD) and run the command:
您无需从网站上独家下载。只要确保你有pip(如果你安装了python,你可能会这样做)。只需打开命令提示符(CMD)并运行命令:
pip install pygame
It will automatically download the correct whl version of pygame compatible with your configuration of PC. Make sure you remember the version which appears while "downloading" as this is the compatible version of .whl packages you shall be looking for in the future.
它将自动下载与您的PC配置兼容的正确的pygame版本。确保您记住“下载”时出现的版本,因为这是您将来要寻找的.whl软件包的兼容版本。
#9
0
Simple steps to install python in Ubuntu:
在Ubuntu中安装python的简单步骤:
-
Download Python
$ cd /usr/src $ wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
-
Extract the downloaded package
解压缩下载的包
$ sudo tar xzf Python-3.6.0.tgz
-
Compile Python source
编译Python源代码
$ cd Python-3.6.0 $ sudo ./configure $ sudo make altinstall
Note
make altinstall
is used to prevent replacing the default python binary file/usr/bin/python
.注意make altinstall用于防止替换默认的python二进制文件/ usr / bin / python。
-
check the python version
检查python版本
# python3.6 -V
下载Python $ cd / usr / src $ wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
#10
0
i have write the answer here How to add/use libraries in Python (3.5.1) but no problem will rewrite it again
我在这里写了答案如何在Python(3.5.1)中添加/使用库,但没有问题会再次重写它
if u have or you can create a file requirements.txt
which contains the libraries that you want to install for ex:
如果您有或者您可以创建一个文件requirements.txt,其中包含您要为ex安装的库:
numpy==1.14.2
Pillow==5.1.0
You gonna situate in your folder which contains that requirements.txt
in my case the path to my project is
您将位于包含items.txt的文件夹中,在我的情况下,我的项目的路径是
C:\Users\LE\Desktop\Projet2_Sig_Exo3\exo 3\k-means
now just type
现在只需输入
python -m pip install -r ./requirements.txt
and all the libararies that you want gonna install
以及你想安装的所有图书馆
C:\Users\LE\Desktop\Projet2_Sig_Exo3\exo 3\k-means>python -m pip install -r ./requirements.txt
#1
19
You want to install a downloaded wheel (.whl) file on Python under Windows?
您想在Windows下在Python上安装下载的wheel(.whl)文件吗?
- 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(在命令行上)
pip install -U pip
-
Install a local wheel file using pip (on the command line)
使用pip安装本地wheel文件(在命令行上)
pip install --no-index --find-links=LocalPathToWheelFile PackageName
在Windows上的Python上安装pip(在Python 3.4+上已经包含它)
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.
选项--no-index告诉pip不要查看pypi.python.org(如果没有安装编译器,许多软件包会失败), - find-links然后告诉pip在哪里寻找。 PackageName是包的名称(numpy,scipy,..第一部分或整个轮文件名)。有关更多信息,请参阅pip的安装选项。
You can execute these commands in the command prompt when switching to your Scripts
folder of your Python installation.
切换到Python安装的Scripts文件夹时,可以在命令提示符中执行这些命令。
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.
注意:它可能仍然是因为它可能包含需要编译的C / C ++源文件而无法在Windows上安装。然后,您需要确保安装了编译器。经常搜索备选的预编译分发是最快的出路。
For example numpy-1.9.2+mkl-cp27-none-win_amd64.whl
has PackageName
numpy
.
例如numpy-1.9.2 + mkl-cp27-none-win_amd64.whl具有PackageName numpy。
#2
8
If you want to be relax for installing libraries for python.
如果你想放松安装python库。
You should using pip
, that is python installer package.
你应该使用pip,即python安装包。
To install pip:
要安装pip:
-
Download ez_setup.py and then run:
下载ez_setup.py,然后运行:
python ez_setup.py
-
Then download get-pip.py and run:
然后下载get-pip.py并运行:
python get-pip.py
-
upgrade installed
setuptools
by pip:通过pip升级安装的setuptools:
pip install setuptools --upgrade
If you got this error:
如果您收到此错误:
Wheel installs require setuptools >= 0.8 for dist-info support. pip's wheel support requires setuptools >= 0.8 for dist-info support.
Add
--no-use-wheel
to above cmd:将--no-use-wheel添加到cmd以上:
pip install setuptools --no-use-wheel --upgrade
Now, you can install libraries for python, just by:
现在,您可以为python安装库,只需:
pip install library_name
For example:
pip install requests
Note that to install some library may they need to compile, so you need to have compiler.
注意,安装某些库可能需要编译,因此需要编译器。
On windows there is a site for Unofficial Windows Binaries for Python Extension Packages that have huge python packages and complied python packages for windows.
在Windows上有一个用于Python扩展包的非官方Windows二进制文件的站点,它具有巨大的python包和用于Windows的编译python包。
For example to install pip
using this site, just download and install setuptools and pip installer from that.
例如,要使用此站点安装pip,只需从中下载并安装setuptools和pip安装程序。
#3
2
To install wheel packages in python 2.7x:
在python 2.7x中安装wheel包:
-
Install python 2.7x (i would recommend python 2.78) - download the appropriate python binary for your version of windows . You can download python 2.78 at this site https://www.python.org/download/releases/2.7.8/ -I would recommend installing the graphical Tk module, and including python 2.78 in the windows path (environment variables) during installation.
安装python 2.7x(我建议使用python 2.78) - 为你的windows版本下载相应的python二进制文件。您可以在此站点下载python 2.78 https://www.python.org/download/releases/2.7.8/ - 我建议安装图形Tk模块,并在安装过程中在Windows路径(环境变量)中包含python 2.78 。
-
Install get-pip.py and setuptools Download the installer at https://bootstrap.pypa.io/get-pip.py Double click the above file to run it. It will install pip and setuptools [or update them, if you have an earlier version of either]
安装get-pip.py和setuptools在https://bootstrap.pypa.io/get-pip.py下载安装程序双击上面的文件运行它。它将安装pip和setuptools [或更新它们,如果你有任何一个的早期版本]
-Double click the above file and wait - it will open a black window and print will scroll across the screen as it downloads and installs [or updates] pip and setuptools --->when it finishes the window will close.
- 双击上面的文件并等待 - 它将打开一个黑色的窗口,打印将在屏幕上滚动,因为它下载并安装[或更新] pip和setuptools --->当它完成时窗口将关闭。
- Open an elevated command prompt - click on windows start icon, enter cmd in the search field (but do not press enter), then press ctrl+shift+. Click 'yes' when the uac box appears.
打开提升的命令提示符 - 单击Windows开始图标,在搜索字段中输入cmd(但不要按回车键),然后按ctrl + shift +。出现uac框时单击“是”。
A-type cd c:\python27\scripts [or cd \scripts ]
A-type cd c:\ python27 \ scripts [或cd \ scripts]
B-type pip install -u Eg to install pyside, type pip install -u pyside
B型pip安装-u例如安装pyside,输入pip install -u pyside
Wait - it will state 'downloading PySide or -->it will download and install the appropriate version of the python package [the one that corresponds to your version of python and windows.]
等待 - 它将声明'下载PySide或 - >它将下载并安装相应版本的python包[与您的python和windows版本对应的版本]。
Note - if you have downloaded the .whl file and saved it locally on your hard drive, type in
pip install --no-index --find-links=localpathtowheelfile packagename
注意 - 如果您已下载.whl文件并将其本地保存在硬盘驱动器上,请键入pip install --no-index --find-links = localpathtowheelfile packagename
**to install a previously downloaded wheel package you need to type in the following command pip install --no-index --find-links=localpathtowheelfile packagename
**要安装以前下载的wheel包,你需要输入以下命令pip install --no-index --find-links = localpathtowheelfile packagename
#4
1
Have you checked this http://docs.python.org/2/install/ ?
你检查过这个http://docs.python.org/2/install/吗?
-
First you have to install the module
首先,您必须安装该模块
$ pip install requests
$ pip安装请求
-
Then, before using it you must import it from your program.
然后,在使用它之前,您必须从程序中导入它。
from requests import requests
来自请求导入请求
Note that your modules must be in the same directory.
请注意,您的模块必须位于同一目录中。
-
Then you can use it.
然后你可以使用它。
For this part you have to check for the documentation.
对于这部分,您必须检查文档。
#5
0
Install distribute by downloading and running distribute_setup.py. This will make easy_install available, and from there you can install pip with easy_install pip. Then you can run pip install CAGE. Using pip to install things is a lot easier than messing with manually running setup.py, because pip can do things like:
通过下载并运行distribute_setup.py来安装分发。这将使easy_install可用,并从那里你可以使用easy_install pip安装pip。然后你可以运行pip install CAGE。使用pip来安装东西要比乱用手动运行setup.py容易得多,因为pip可以执行以下操作:
automatically resolve dependencies
show you a list of all installed packages and their versions
install a set of specified packages from a requirements.txt
upgrade and uninstall packages
work with virtualenv
If you're on Windows, the one downside of pip occurs when there are C library dependencies, as pip will want a C toolchain installed so it can compile things. If that is the case, then there are two options. If there are precompiled binaries on PyPI, then just run easy_install package instead; easy_install knows how to use binary packages. You can also check Christoph Gohlke's site for executable installers of many binary packages. These can also be installed by easy_install if you want to use them with a virtualenv (just point it to the path of the .exe) or you can click and run if you don't care about virtualenv.
如果您使用的是Windows,那么当存在C库依赖项时,pip会出现一个缺点,因为pip需要安装C工具链才能编译。如果是这种情况,那么有两种选择。如果PyPI上有预编译的二进制文件,那么只需运行easy_install包; easy_install知道如何使用二进制包。您还可以查看Christoph Gohlke的网站,了解许多二进制包的可执行安装程序。如果你想将它们与virtualenv一起使用(只需将它指向.exe的路径),也可以通过easy_install安装它们,或者如果你不关心virtualenv,你可以点击并运行。
The main point is that no matter what route you choose to install packages, at no point are you ever moving around files by hand. You need to get out of the mindset of "I extracted this archive, where do I put these .py files?" That's not how it works. You're either running pip, running easy_install, running setup.py, clicking on an installer package, or using your distribution's installer. At no point are you ever doing anything by hand with the files directly.
重点是,无论您选择安装包的路线是什么,您都不会手动移动文件。你需要摆脱“我提取这个档案,我在哪里放这些.py文件?”的心态。这不是它的工作原理。您要么运行pip,运行easy_install,运行setup.py,单击安装程序包,要么使用分发的安装程序。在任何时候你都没有直接手工处理文件。
#6
0
Once you have a library downloaded you can execute this from the MS-DOS command box:
下载库后,可以从MS-DOS命令框执行此操作:
python setup.py install
The setup.py
is located inside every library main folder.
setup.py位于每个库主文件夹中。
#7
0
For windows, there are automatic installer packages available at this site
对于Windows,此站点提供自动安装程序包
It includes most of the python packages.
它包括大多数python包。
But the best way for it is of course using pip.
但最好的方法当然是使用pip。
#8
0
You don't need to download exclusively from the website. Just make sure you have pip (which you probably will if you have python installed). Just open your Command Prompt (CMD) and run the command:
您无需从网站上独家下载。只要确保你有pip(如果你安装了python,你可能会这样做)。只需打开命令提示符(CMD)并运行命令:
pip install pygame
It will automatically download the correct whl version of pygame compatible with your configuration of PC. Make sure you remember the version which appears while "downloading" as this is the compatible version of .whl packages you shall be looking for in the future.
它将自动下载与您的PC配置兼容的正确的pygame版本。确保您记住“下载”时出现的版本,因为这是您将来要寻找的.whl软件包的兼容版本。
#9
0
Simple steps to install python in Ubuntu:
在Ubuntu中安装python的简单步骤:
-
Download Python
$ cd /usr/src $ wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
-
Extract the downloaded package
解压缩下载的包
$ sudo tar xzf Python-3.6.0.tgz
-
Compile Python source
编译Python源代码
$ cd Python-3.6.0 $ sudo ./configure $ sudo make altinstall
Note
make altinstall
is used to prevent replacing the default python binary file/usr/bin/python
.注意make altinstall用于防止替换默认的python二进制文件/ usr / bin / python。
-
check the python version
检查python版本
# python3.6 -V
下载Python $ cd / usr / src $ wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
#10
0
i have write the answer here How to add/use libraries in Python (3.5.1) but no problem will rewrite it again
我在这里写了答案如何在Python(3.5.1)中添加/使用库,但没有问题会再次重写它
if u have or you can create a file requirements.txt
which contains the libraries that you want to install for ex:
如果您有或者您可以创建一个文件requirements.txt,其中包含您要为ex安装的库:
numpy==1.14.2
Pillow==5.1.0
You gonna situate in your folder which contains that requirements.txt
in my case the path to my project is
您将位于包含items.txt的文件夹中,在我的情况下,我的项目的路径是
C:\Users\LE\Desktop\Projet2_Sig_Exo3\exo 3\k-means
now just type
现在只需输入
python -m pip install -r ./requirements.txt
and all the libararies that you want gonna install
以及你想安装的所有图书馆
C:\Users\LE\Desktop\Projet2_Sig_Exo3\exo 3\k-means>python -m pip install -r ./requirements.txt