1,下载安装 Virtualenv
pip install virtualenv
2,创建虚拟环境
进入要创建的目录后,创建虚拟环境的文件夹,进入文件夹,创建虚拟环境
C:\Users\DP\Documents\pyWork>mkdir newproj1 C:\Users\DP\Documents\pyWork>cd newproj1 C:\Users\DP\Documents\pyWork\newproj1>virtualenv venv created virtual environment CPython3.8.4.final.0-64 in 4854ms creator CPython3Windows(dest=C:\Users\DP\Documents\pyWork\newproj1\venv, 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\DP\AppData\Local\pypa\virtualenv) added seed packages: pip==22.3.1, setuptools==65.6.3, wheel==0.38.4 activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
3,激活虚拟环境,在虚拟环境中启动idle
C:\Users\DP\Documents\pyWork\newproj1>venv\scripts\activate (venv) C:\Users\DP\Documents\pyWork\newproj1>python -m idlelib.idle &
4,此时,idle打开,可以使用了
5,使用完后,手动关闭IDLE,退出虚拟环境
# 激活环境 C:\Users\DP\Documents\pyWork\newproj1>venv\scripts\activate # 打开IDLE (venv) C:\Users\DP\Documents\pyWork\newproj1>python -m idlelib.idle & # 打开IDLE后会卡在这里 # 关闭IDLE后 (venv) C:\Users\DP\Documents\pyWork\newproj1>deactivate C:\Users\DP\Documents\pyWork\newproj1>
标签:Virtualenv,Documents,Users,idle,venv,pyWork,win10,newproj1,DP From: https://www.cnblogs.com/jichao1515/p/16984379.html