whindows cmd 下建立不同版本python的虛擬環境;
阿新 • • 發佈:2020-12-09
Microsoft Windows [版本 10.0.17763.1577] (c) 2018 Microsoft Corporation。保留所有權利。
首先:安裝virtualenv
pipinstallvirtualenv
pipinstallvirtualenvwrapper-win
然後:開始建立虛擬環境
1.檢視當著的python版本: C:\Users\Administrator>python Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" formore information. >>> ^Z 2.切換到建立python虛擬環境的路徑: C:\Users\Administrator>F: F:\>cd F:\0_Work\4_python\python36venv 3.使用命令建立虛擬環境: virtualenv -p C:\Programs\Python\python36\python.exe venv36 (virtualenv -p + "python解析器在環境變更中的路徑" + "python虛擬環境的名字") F:\0_Work\4_python\python36venv>virtualenv -p C:\Programs\Python\python36\python.exe venv36 created virtual environment CPython3.6.8.final.0-64 in 3209ms creator CPython3Windows(dest=F:\0_Work\4_python\python36venv\venv36, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\Administrator\AppData\Local\pypa\virtualenv) added seed packages: pip==20.3.1, setuptools==51.0.0, wheel==0.36.1 activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator 4.進入建立的虛擬環境: F:\0_Work\4_python\python36venv>cd venv36 F:\0_Work\4_python\python36venv\venv36>dir 驅動器 F 中的卷是 新加捲 卷的序列號是 6E6C-5054 F:\0_Work\4_python\python36venv\venv36 的目錄 2020/12/09 18:01 <DIR> . 2020/12/09 18:01 <DIR> .. 2020/12/09 18:01 42 .gitignore 2020/12/09 18:01 <DIR> Lib 2020/12/09 18:01 300 pyvenv.cfg 2020/12/09 18:01 <DIR> Scripts 2 個檔案 342 位元組 4 個目錄 265,085,833,216 可用位元組 5.使用新建立的虛擬環境: F:\0_Work\4_python\python36venv\venv36>Scripts\activate.bat 6.檢視虛擬環境使用的python版本 (venv36) F:\0_Work\4_python\python36venv\venv36>python Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> ^Z 7.退出虛擬環境: (venv36) F:\0_Work\4_python\python36venv\venv36>Scripts\deactivate.bat F:\0_Work\4_python\python36venv\venv36>