VSCode pipenv运行REPL程序接收到环境激活,导致初始语法错误

时间:2018-12-04 13:31:25

标签: python visual-studio-code task virtualenv pipenv

Python环境的自动供应/启用是一个很棒的功能!但是我不知道如何为任务禁用它。例如,Pyenv在其virtualenv中自动激活并运行命令,因此我的pipenv运行命令最终出错。 我已经用行为制作了一些GIF。

enter image description here

作为参考,这是我的.vscode / tasks.json文件

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [{
        "label": "Run IPython Shell",
        "problemMatcher": [],
        "type": "shell",
        "command": "pipenv run ipython",
        "presentation": {
            "echo": true,
            "reveal": "always",
            "focus": true,
            "panel": "shared",
            "showReuseMessage": true,
            "clear": false
        }
    }]
}

输出如下:

> Executing task: pipenv run ipython <

source /Users/nahuel/.virtualenvs/pysrv-RjlHvHY5/bin/activate
Python 3.6.6 (default, Aug  6 2018, 12:14:58)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: source /Users/nahuel/.virtualenvs/pysrv-RjlHvHY5/bin/activate
  File "<ipython-input-1-944ce73c2717>", line 1
    source /Users/nahuel/.virtualenvs/pysrv-RjlHvHY5/bin/activate
                         ^
SyntaxError: invalid syntax


In [2]:

1 个答案:

答案 0 :(得分:0)

This is not an issue in current versions of VSCode. The environment activation works for both pipenv and poetry, and can be customized from settings.