安装命令
pip install virtualenv
pip install virtualenv-win
控制面板-Administrator环境变量配置
VIRTUALENV_CONFIG_FILE=E:\ENVS\virtualenv.ini
Powershell设置
一、Powershell终端输入下列命令
python
Test-Path $profile
New-Item -path $profile -type file --force
上述命令会生成一个文件
二、
C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
内容修改如下:
python
Set-Alias py3.6 E:\ENVS\python3.6\Scripts\activate.ps1
Set-Alias py3.11 E:\ENVS\python3.11\Scripts\activate.ps1
E:\ENVS\python3.6\Scripts\activate.ps1
activate.ps1是默认就有的,不用修改
cmd调试用命令
查看历史命令doskey /history
Powershell调试用命令
|-------------------------------------------------|--------|
| 命令行 | 用途 |
| type .\Microsoft.PowerShell_profile.ps1 | 查看文件内容 |
| get-content .\Microsoft.PowerShell_profile.ps1 | 查看文件内容 |
Powershell修改脚本执行权限
python
PS C:\Users\Administrator\documents\windowspowershell> get-executionpolicy
Restricted
PS C:\Users\Administrator\documents\windowspowershell> set-ExecutionPolicy RemoteSigned
PS C:\Users\Administrator\documents\windowspowershell> get-executionpolicy
RemoteSigned
整合Sublime
Ctrl+Shift+P
安装
install package、virtualenv
preference->Package settings->Virtualenv->Settings - User
添加内容如下:
{
"virtualenv_directories":
["E:\\ENVS",
"E:\\ENVS\\python3.6",
"E:\\ENVS\\python3.11",
]
}
①输入virtualenv,选择activate
②选择虚拟环境版本

③Sublime中选择Tools->Build System->Python+Virtualenv(这一步的作用是,依赖会找到虚拟环境中的依赖)
最终效果如下
一打开powershell会自动进入虚拟环境

一些尚不确定的东西
app_data_dir=C:\Users\Administrator\AppData\Local\pypa\virtualenv(这个不知道有啥用,看了下文件,都是一些pip相关的whl文件,好像没法修改位置)