开发简单的python项目,可以选择选择使用 Anaconda + VS Code 的搭配,在环境管理和编码体验上都算不错。编码体验方面,使用 VS Code 默认推荐安装的插件即可。
Python Language Support
Python 语言支持,可以在左下角选择 conda 环境。(会自动安装一揽子插件,可以选择性卸载)
SQLite
可以在 VS Code 中查看数据库
Highlight String Code
字符串高亮(如 sql 语句)
在 VSCode 集成终端中使用 Anaconda 时遇到了一个问题,默认的 PowerShell 终端无法激活 conda 环境。下面是整理自 Stack Overflow 的解决方案:
打开一个 Anaconda Powershell Prompt
, 首先:
conda init powershell
重启 powershell,如果遇到如下问题:
WindowsPowerShell\profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3
我们需要改变执行协议,在 powershell 中运行其中之一:
# 需要管理员权限
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
# 无需管理员权限
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
参考文档: execution policy
如果不想 conda 自动激活 base 环境,可以运行:
conda config --set auto_activate_base false