formulahendry / formulahendry/vscode-code-runner

pipenv venv not activated before Code Runner executes Python script file

Open
#395 37 comments 9 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.4k
Forks
351
PR merge metrics
No merged PRs in 30d

Description

Windows 10 1803 (17134.407)
Python 3.7.1
pipenv 2018.10.13
VSCode 1.29.1
Code Runner 0.9.5

When running a Python script using Code Runner the virtualenv is not activated before the code is run in the terminal for the first time, causing my code fail. The virtualenv is activated after the script fails and I can then run my code successfully until I close the terminal window. A minimal working example is shown below.

![code-runner](https://user-images.githubusercontent.com/2662123/48879987-32b61700-edc3-11e8-920b-0f5f71df1c3d.gif)

The venv is activated in VSCode and the correct Python interpreter is configured.

Here is the Pipfile for the project:

```
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
numpy = "*"

[dev-packages]

[requires]
python_version = "3.7"
```

And here are all the Code Runner settings from my settings.json file:

```
{
"code-runner.fileDirectoryAsCwd": true,
"code-runner.respectShebang": false,
"code-runner.ignoreSelection": true,
}
```

While I can get my code to work this is rather annoying. Does anyone have any ideas what might be causing this?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.