windows下Python2與Python3共存的使用方法__Python

來源:互聯網
上載者:User

安裝環境:

Windows版本:Windows 10 家庭中文版

Python 2 版本:Python 2.7.11

Python 3 版本:Python 3.5.2


1.安裝Python

Python官方下載地址:https://www.python.org/downloads/

分別安裝Python 2 和Python 3兩個版本的Python,我是安裝在C盤的不同目錄下



雙擊運行msi格式檔案,安裝時選擇安裝pip並增加到環境變數


(圖片來自廖雪峰的部落格)


2.調用不同版本的Python

使用快速鍵Win+R調查“運行”,輸入“cmd”進入命令列工具



調用Python 2 時,使用 py -2



調用Python 3 時,使用 py -3



3.使用pip安裝庫

安裝到Python 2 時,就使用 pip2 install [name],比如:pip2 install bs4


安裝到Python 3 時,就使用pip3 install [name],比如:pip3 install bs4


4.在PyCharm中切換

如果你使用的是PyCharm編寫Python,當需要切換Python版本時,只需要在設定中搜尋“Project Interpreter”,然後進行切換即可,同時可以看到已經安裝到該版本中的庫。



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.