我很難設置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