Win7 Python2.7.6 安裝pip,setuptools,win7python2.7.6

來源:互聯網
上載者:User

Win7 Python2.7.6 安裝pip,setuptools,win7python2.7.6

1.先安裝python2.7.6解析器

2.下載 ez_setup.py:代碼資源

從cmd進入當前路徑(可以找到的ez_setup.py地方,筆者將其放到的安裝python的路徑下),執行:
python ez_setup.py

但是在安裝setuptools遇到如下問題:

  mimetypes.init() # try to read system mime.types  File "J:\Program Files (x86)\Python\Python27\lib\mimetypes.py", line 358, init    db.read_windows_registry()  File "J:\Program Files (x86)\Python\Python27\lib\mimetypes.py", line 258, iead_windows_registry    for subkeyname in enum_types(hkcr):  File "J:\Program Files (x86)\Python\Python27\lib\mimetypes.py", line 249, inum_types    ctype = ctype.encode(default_encoding) # omit in 3.x!UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinnot in range(128)

應該是編碼問題 百度問題解決如下:
解決方案:開啟D:\Python27\Lib下的 mimetypes.py 檔案(自己解析器安裝路徑),找到256行的

default_encoding = sys.getdefaultencoding()
改成:

if sys.getdefaultencoding() != ‘gbk’:
reload(sys)
sys.setdefaultencoding(‘gbk’)
default_encoding = sys.getdefaultencoding()
但是注意:python代碼 有著嚴格的縮排,添加代碼時注意縮排,否則運行指令碼還是無法安裝;
筆者縮排如下:

安裝完畢之後會在系統目錄下產生Scripts目錄(安裝python/Scripts/),裡面有 :

easy_install.exe;

3.安裝pip資源管理組件:
從cmd進入:~(安裝python路徑下面)/Scripts檔案,執行:
easy_install.exe pip;

D:\Python27\Scripts>easy_install.exe pip

安裝pip;

4,查看是否成功安裝:pip
在命令列輸入: pip

出現pip 不是內部或外部指令

此時還需將pip,setuptools的環境變數配好;
在系統內容變數Path中:加入D:\Python27\Scripts

5.完成;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.