我很难设置python包。来自SetupTools的EasyInstall应该有帮助,但它们没有Python 2.6的可执行文件。
例如,要安装Mechanize,我应该根据INSTALL.txt将Mechanize文件夹放在C:\ Python24 \ Lib \ site-packages中,但运行测试不起作用。有人可以帮助解释一下吗?谢谢!
accepted answer已经过时了。首先,pip
优于easy_install
,(Why use pip over easy_install?)。然后按照以下步骤在Windows上安装pip
,这很容易。
setuptools
:
curl https://bootstrap.pypa.io/ez_setup.py | python
pip
:
curl https://bootstrap.pypa.io/get-pip.py | python
pip
。它就像C:\Python33\Scripts
。pip是python的软件包安装程序,首先更新它,然后下载你需要的东西
python -m pip install --upgrade pip
然后:
python -m pip install <package_name>
较新版本的Python for Windows附带了pip包管理器。 (source)
如果您使用的是Python 2> = 2.7.9或Python 3> = 3.4,则已经安装了pip
用它来安装包:
cd C:\Python\Scripts\
pip.exe install <package-name>
所以在你的情况下,它是:
pip.exe install mechanize
This是一个很好的教程,如何在Windows上获得easy_install
。简短的回答:将C:\Python26\Scripts
(或您安装的任何python)添加到PATH中。
您不需要setuptools的可执行文件。您可以下载源代码,解压缩,遍历到下载的目录并在命令提示符下运行python setup.py install
从Python 2.7开始,默认包含pip。只需通过下载您想要的包裹
python -m pip install [package-name]
用Python打包是可怕的。根本原因是该语言没有包管理器。
幸运的是,Python有一个包管理器,名为Pip。 Pip的灵感来自Ruby的宝石,但缺乏一些功能。具有讽刺意味的是,Pip本身就是complicated to install。在流行的64位Windows上安装需要从源代码构建和安装两个软件包。对于任何刚接触编程的人来说,这是一个很大的问
所以正确的做法是安装pip。但是,如果你不能打扰,Christoph Gohlke为所有Windows平台http://www.lfd.uci.edu/~gohlke/pythonlibs/提供流行Python包的二进制文件
实际上,构建一些Python包需要C编译器(例如mingw32)和依赖项的库头。这可能是Windows上的噩梦,所以请记住Christoph Gohlke这个名字。
我在Windows上安装软件包时遇到问题。找到了解决方案。它适用于Windows7 +。主要是Windows Powershell的任何东西都应该能够使它工作。 This可以帮助您开始使用它。
python setup.py install
当没有别的意义时,那对我有用。我使用的是Python 2.7,但是文档表明同样适用于Python 3.x.
您也可以下载并运行ez_setup.py,尽管SetupTools文档不再建议这样做。最近两周前我的工作很好。
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可执行文件中。