VSCode pipenv run REPL程序接收环境激活导致初始语法

2024-09-29 21:38:45 发布

您现在位置:Python中文网/ 问答频道 /正文

Python环境的自动寻源/启用是一个很好的特性!但我不知道如何为任务禁用它。例如,Pyenv在其virtualenv中自动激活并运行命令,因此我的pipenv run命令最终会出错。 我对这种行为做了一点小小的调整。你知道吗

enter image description here

作为参考,这是我的.vscode/任务.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]:

Tags: run命令jsontruesourceforbinpipenv

热门问题