formulahendry / vscode-code-runner

Code Runner for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner
MIT License
2.2k stars 293 forks source link

[Bug]The Python interpreter that CodeRunner uses to execute python code is always the global interpreter. #1081

Open leij0318 opened 11 months ago

leij0318 commented 11 months ago

I don't know why the Python interpreter that CodeRunner takes effect is always the global interpreter, not the default python interpreter set. The global interpreter I am talking about is the python interpreter with the word global at the end after opening the command panel in VScode and entering python. Now you can only specify the python interpreter path in "code-runner.executorMap" in setting.json.

The above situation I mentioned is that CodeRunner does not execute in the terminal by default. Of course, it will not be wrong if it is executed in the terminal, but my default terminal powershell is integrated in the windows terminal. When executing, I must first activate the current environment. Dislike the slow startup speed.

leij0318 commented 11 months ago

Can anyone tell me how to modify or cancel the python global interpreter?

RainyCityCoder commented 10 months ago

Try putting the path to your Python executable in settings.json:

"code-runner.executorMap": {
    "python": "path-to-your-env-python-executable-here"
  }

For example, mine would be:

"code-runner.executorMap": {
    "python": "/home/user/anaconda3/envs/vsc/bin/python"
  }
jackyhevey commented 6 months ago

try this setting "code-runner.executorMap": { "python": "$pythonPath $fullFileName" }, "code-runner.respectShebang": false