【问题标题】:VSCode pipenv run REPL program receives environment activation causing initial syntax errorVSCode pipenv 运行 REPL 程序接收环境激活导致初始语法错误
【发布时间】:2018-12-04 13:31:25
【问题描述】:

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

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

【问题讨论】:

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


    【解决方案1】:

    这在当前版本的 VSCode 中不是问题。环境激活适用于 pipenv 和诗歌,并且可以从设置中自定义。

    【讨论】:

      猜你喜欢
      • 2019-03-23
      • 1970-01-01
      • 1970-01-01
      • 2012-09-19
      • 2017-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多