win10下安裝python2與python3以及pip共存
阿新 • • 發佈:2017-07-23
用戶目錄 strong exe 路徑 org enc setup 最新版 .com
一 分別安裝python2和python3
註意: 安裝時記得勾選 Add Python.exe to Path
二 安裝pip
Python3最新版本有pip,無需安裝
Python2:
- 下載pip安裝包: https://pypi.python.org/pypi/pip#downloads
2. 進入解壓路徑,執行命令以下命令:py -2 setup.py install
分別進入python和python3的pip目錄下,刪除pip.exe
python2安裝模塊執行命令: pip2 install sth
python3 安裝模塊執行命令: pip3 install sth
三 報錯
pip2 install Pillow可能報錯
Exception:
Traceback (most recent call last):
......
......
UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xb1 in position 9: ordinal
not in range(128)
問題參考:https://www.v2ex.com/t/90659
解決方法:安裝模塊時會加載用戶目錄,目錄為中文,ascii不能編碼
在 Python27\Lib\site-packages 建一個文件sitecustomize.py
加入以下內容
import sys
sys.setdefaultencoding(‘gb2312‘)
win10下安裝python2與python3以及pip共存