我很难设置python包。从SetupTools EasyInstall应该可以帮助,但他们没有Python 2.6的可执行文件。如何在Windows上安装Python软件包?
例如,要安装Mechanize,我只是应该根据INSTALL.txt将Mechanize文件夹放在C:\ Python24 \ Lib \ site-packages中,但是运行测试不起作用。有人可以帮助解释这一点吗?谢谢!
我很难设置python包。从SetupTools EasyInstall应该可以帮助,但他们没有Python 2.6的可执行文件。如何在Windows上安装Python软件包?
例如,要安装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
。
,这是唯一为我工作的人。 我的环境 - Python 3.3.1,Windows 7 64bit,x64 PC。如果可能的话,请注意这一点,为PPL节省很多麻烦。 – 2013-05-10 01:54:46
上面的工作对我来说,但第二次与https发出警告关于ssl证书过期。必须在卷曲命令行上使用--insecure – Anton 2013-06-24 13:37:29
1st答案仍然有效,但PIP优于IMO – 2013-10-08 13:46:23
您不需要setuptools的可执行文件。 您也可以下载源代码,解压缩,运行到下载目录,并运行在命令提示符下
感谢您的回应!我在哪里解开它并在哪里运行该命令? – echoblaze 2009-09-19 21:07:43
如果您下载了tar文件,只需使用WinRAR等程序将其解压缩即可。完成之后,打开命令提示符并导航到解压缩的文件夹(如果您看到'setup.py'文件,您将知道自己处于正确的位置)。从那里你可以运行'python setup.py install',它会为你安装它。 – 2009-09-19 21:27:46
您也可以下载并运行ez_setup.py,但SetupTools文档不再提示这一点。就在2周前,我工作得很好。
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.
所以做正确的事就是安装点子。然而,如果你不能被打扰,Christoph Gohlke为所有Windows平台提供流行的Python软件包的二进制代码http://www.lfd.uci.edu/~gohlke/pythonlibs/
实际上,构建一些Python包需要一个C编译器(例如mingw32)和依赖关系的库头。这可能是Windows上的噩梦,所以请记住名字Christoph Gohlke。
我在Windows上安装软件包时遇到了问题。找到解决方案。它适用于Windows7 +。 Windows Powershell的任何主要功能都应该能够使其工作。 This可以帮助您开始使用它。
python setup.py install
这为我工作的时候没有别的作出任何意义PY。我使用Python 2.7,但是文档表明这同样适用于Python 3.x。
更新版本的Python for Windows附带pip程序包管理器。 (source)
pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4
用它来安装软件包:
cd C:\Python\Scripts\
pip.exe install <package-name>
所以你的情况这会是:
pip.exe install mechanize
+1,因为这明确说在哪里键入“pip install
正如这是一个很好的答案!它当然假定python安装在c盘中。对于使用PowerShell的用户,如果您将python安装到其路径中有空格的目录中,请使用cd(“path”)更改目录。 – stt106 2015-09-23 20:59:43
即使使用Python 2.7,这在Windows 10上也能很好地工作。感谢面向Windows的答案,这并没有让我的眼睛茫然。 – brichins 2016-06-03 15:50:55
与Python 2.7开始,PIP默认情况下包括在内。只需通过
python -m pip install [package-name]
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
下载你想要的包或只是把目录画中画可执行在你的系统路径。
截至2014年3月,[所有平台上的Python 3.4都包含pip软件包管理器,包括Windows](https://docs.python.org/3/whatsnew/3.4.html#whatsnew-pep-453 )。所以确保你运行Python 3.4可能是一个不错的选择。 – 2014-06-03 07:01:40
安装python 2.7.10或3.4以上版本,其中默认使用pip。然后使用python -m pip在cmd中安装Django等等 – userRaj 2015-11-30 08:20:16