问题:如何在Windows上安装Python软件包?
我很难设置python软件包。应该可以使用SetupTools的 EasyInstall来解决此问题,但是它们没有适用于Python 2.6的可执行文件。
例如,要安装Mechanize,我只想根据INSTALL.txt将Mechanize文件夹放在C:\ Python24 \ Lib \ site-packages中,但运行测试无效。有人可以帮忙阐明一下吗?谢谢!
I’m having a hard time setting up python packages. EasyInstall from SetupTools is supposed to help that, but they don’t have an executable for Python 2.6.
For instance to install Mechanize, I’m just supposed to put the Mechanize folder in C:\Python24\Lib\site-packages according to INSTALL.txt, but runnning the tests does not work. Can someone help shed some light on this? Thanks!
回答 0
该接受的答案是过时的。因此,首先要优先于easy_install
,(为什么要在easy_install上使用pip?)。然后按照以下步骤pip
在Windows上安装,这非常容易。
安装setuptools
:
curl https://bootstrap.pypa.io/ez_setup.py | python
安装pip
:
curl https://bootstrap.pypa.io/get-pip.py | python
(可选)您可以将路径添加到您的环境,以便可以pip
在任何地方使用。就像C:\Python33\Scripts
。
The accepted answer is outdated. So first, is preferred over easy_install
, (Why use pip over easy_install?). Then follow these steps to install pip
on Windows, it’s quite easy.
Install setuptools
:
curl https://bootstrap.pypa.io/ez_setup.py | python
Install pip
:
curl https://bootstrap.pypa.io/get-pip.py | python
Optionally, you can add the path to your environment so that you can use pip
anywhere. It’s somewhere like C:\Python33\Scripts
.
回答 1
pip软件包管理器随附了Windows的较新版本的Python 。(资源)
如果您使用的是Python 2> = 2.7.9或Python 3> = 3.4,则已经安装了pip
使用它来安装软件包:
cd C:\Python\Scripts\
pip.exe install <package-name>
因此,在您的情况下,它将是:
pip.exe install mechanize
Newer versions of Python for Windows come with the pip package manager. (source)
pip is already installed if you’re using Python 2 >=2.7.9 or Python 3 >=3.4
Use that to install packages:
cd C:\Python\Scripts\
pip.exe install <package-name>
So in your case it’d be:
pip.exe install mechanize
回答 2
这是有关如何easy_install
在Windows 上获得良好的教程。简短的答案:将C:\Python26\Scripts
(或安装的任何python)添加到PATH。
This is a good tutorial on how to get easy_install
on windows. The short answer: add C:\Python26\Scripts
(or whatever python you have installed) to your PATH.
回答 3
您不需要setuptools的可执行文件。您可以下载源代码,解压缩它,遍历下载的目录并python setup.py install
在命令提示符下运行
You don’t need the executable for setuptools.
You can download the source code, unpack it, traverse to the downloaded directory and run python setup.py install
in the command prompt
回答 4
从Python 2.7开始,默认情况下包含pip。只需通过以下网址下载所需的软件包
python -m pip install [package-name]
Starting with Python 2.7, pip is included by default. Simply download your desired package via
python -m pip install [package-name]
回答 5
正如我在其他地方写的
用Python打包很可怕。根本原因是该语言在没有软件包管理器的情况下出厂。
幸运的是,有一个用于Python的软件包管理器,称为Pip。Pip受Ruby’s Gem的启发,但缺少一些功能。具有讽刺意味的是,Pip本身安装起来很复杂。在流行的64位Windows上进行安装需要从源代码构建和安装两个软件包。对于任何刚接触编程的人来说,这都是一个很大的要求。
因此,正确的做法是安装pip。但是,如果您不介意的话,Christoph Gohlke将为所有Windows平台的流行Python软件包提供二进制文件http://www.lfd.uci.edu/~gohlke/pythonlibs/
实际上,构建某些Python软件包需要C编译器(例如mingw32)和依赖项的库头。在Windows上这可能是一场噩梦,因此请记住克里斯托夫·戈尔克(Christoph Gohlke)的名字。
As I wrote elsewhere
Packaging in Python is dire. The root cause is that the language ships without a package manager.
Fortunately, there is one package manager for Python, called Pip. Pip is inspired by Ruby’s Gem, but lacks some features. Ironically, Pip itself is complicated to install. Installation on the popular 64-bit Windows demands building and installing two packages from source. This is a big ask for anyone new to programming.
So the right thing to do is to install pip. However if you can’t be bothered, Christoph Gohlke provides binaries for popular Python packages for all Windows platforms http://www.lfd.uci.edu/~gohlke/pythonlibs/
In fact, building some Python packages requires a C compiler (eg. mingw32) and library headers for the dependencies. This can be a nightmare on Windows, so remember the name Christoph Gohlke.
回答 6
我在Windows上安装软件包时遇到问题。找到了解决方案。它适用于Windows7 +。主要是任何使用Windows Powershell的东西都应该能够使其工作。这可以帮助您开始使用它。
- 首先,您需要将python安装添加到PATH变量中。这应该有所帮助。
- 您需要下载要安装的zip格式的软件包,然后将其解压缩。如果是一些奇怪的zip格式,请使用7Zip,并且应该将其解压缩。
- 使用Windows Powershell导航到setup.py提取的目录(如果遇到问题,请使用链接)
- 运行命令
python setup.py install
当没有其他意义的时候,这对我有用。我使用的是Python 2.7,但文档显示,同样适用于Python3.x。
I had problems in installing packages on Windows. Found the solution. It works in Windows7+. Mainly anything with Windows Powershell should be able to make it work. This can help you get started with it.
- Firstly, you’ll need to add python installation to your PATH variable. This should help.
- You need to download the package in zip format that you are trying to install and unzip it. If it is some odd zip format use 7Zip and it should be extracted.
- Navigate to the directory extracted with setup.py using Windows Powershell (Use link for it if you have problems)
- Run the command
python setup.py install
That worked for me when nothing else was making any sense. I use Python 2.7 but the documentation suggests that same would work for Python 3.x also.
回答 7
pip是python的软件包安装程序,请先对其进行更新,然后再下载所需的文件
python -m pip install --upgrade pip
然后:
python -m pip install <package_name>
pip is the package installer for python, update it first, then download what you need
python -m pip install --upgrade pip
Then:
python -m pip install <package_name>
回答 8
通过命令提示符升级pip(Python目录)
D:\Python 3.7.2>python -m pip install --upgrade pip
现在您可以安装所需的模块
D:\Python 3.7.2>python -m pip install <<yourModuleName>>
Upgrade the pip via command prompt ( Python Directory )
D:\Python 3.7.2>python -m pip install --upgrade pip
Now you can install the required Module
D:\Python 3.7.2>python -m pip install <<yourModuleName>>
回答 9
您也可以下载并运行ez_setup.py,尽管SetupTools文档不再建议这样做。最近两周前对我来说还不错。
You can also just download and run ez_setup.py, though the SetupTools documentation no longer suggests this. Worked fine for me as recently as 2 weeks ago.
回答 10
PS D:\simcut> C:\Python27\Scripts\pip.exe install networkx
Collecting networkx
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:318: SNIMissingWarning: An HTTPS reques
t has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may caus
e the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer ve
rsion of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissi
ngwarning.
SNIMissingWarning
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SS
LContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL con
nections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.
readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading networkx-1.11-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 664kB/s
Collecting decorator>=3.4.0 (from networkx)
Downloading decorator-4.0.11-py2.py3-none-any.whl
Installing collected packages: decorator, networkx
Successfully installed decorator-4.0.11 networkx-1.11
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object i
s not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade
to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplat
formwarning.
InsecurePlatformWarning
或者只是将目录放在系统路径中的pip可执行文件中。
PS D:\simcut> C:\Python27\Scripts\pip.exe install networkx
Collecting networkx
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:318: SNIMissingWarning: An HTTPS reques
t has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may caus
e the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer ve
rsion of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissi
ngwarning.
SNIMissingWarning
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SS
LContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL con
nections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.
readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading networkx-1.11-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 664kB/s
Collecting decorator>=3.4.0 (from networkx)
Downloading decorator-4.0.11-py2.py3-none-any.whl
Installing collected packages: decorator, networkx
Successfully installed decorator-4.0.11 networkx-1.11
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object i
s not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade
to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplat
formwarning.
InsecurePlatformWarning
Or just put the directory to your pip executable in your system path.
回答 11
正如Blauhirn所说,预装2.7点后。如果对您不起作用,则可能需要将其添加到路径中。
但是,如果您运行Windows 10,则无需再打开终端来安装模块。打开Python也是如此。
您可以直接在搜索菜单中输入pip install mechanize
,选择命令,它将安装:
如果出了什么问题,它可能会在您读取错误之前关闭,但这仍然是有用的快捷方式。
As mentioned by Blauhirn after 2.7 pip is preinstalled. If it is not working for you it might need to be added to path.
However if you run Windows 10 you no longer have to open a terminal to install a module. The same goes for opening Python as well.
You can type directly into the search menu pip install mechanize
, select command and it will install:
If anything goes wrong however it may close before you can read the error but still it’s a useful shortcut.
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。