所以...您知道那些时候向他人解释问题并突然回答吗?这是其中之一。以下是我的原始帖子,距离提交的片刻距离我有一个想法来解决这个问题!阅读...
我正在研究一个基于电子的项目,该项目我在VSCODE中进行了调试。该代码的一部分产生了用Python编写的几个外部服务。这些服务刚刚从Python 2.7转移到Python 3.7,我为此目的设置了一个Virtualenv(我正在使用2.7的Ubuntu 16,所以我犹豫不决地将python
和pip
重新映射到新版本(。
问题在于,我需要一种在调试会话开始时激活Virtualenv的方法,就好像电子是在bash shell中启动的(我激活了.bashrc中的Virtualenv(。所以我的问题是:如何在调试会话期间激活虚拟的?
为了完整性,这是我当前的启动配置:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Electron Shell",
"cwd": "${workspaceFolder}/dist",
"runtimeExecutable": "${workspaceFolder}/dist/node_modules/electron/dist/electron",
"runtimeArgs": ["app.js", "--remote-debugging-port=9222"],
"protocol": "inspector",
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Electron Shell",
"port": 9222,
"webRoot": "${workspaceFolder}/src",
"timeout": 30000
}
],
"compounds": [
{
"name": "Debug Angular In Electron Shell",
"configurations": [
"Attach to Electron Shell",
"Launch Electron Shell",
]
}
]
}
答案,事实证明只是做activate
脚本所做的事情:修改PATH
和UNSET PYTHONHOME
。喜欢:
{
"type": "node",
"request": "launch",
"name": "Launch Electron Shell",
"cwd": "${workspaceFolder}/dist",
"runtimeExecutable": "${workspaceFolder}/dist/node_modules/electron/dist/electron",
"runtimeArgs": ["app.js", "--remote-debugging-port=9222"],
"protocol": "inspector",
"env": {
"PATH": "/path/to/virtualenv/folder/bin:${env:PATH}",
"PYTHONHOME": null
}
},