microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.32k stars 1.19k forks source link

Interpreter not Picked up From `settings.json`, and Multiple Paths not Working #14798

Closed RishabhMalviya closed 3 years ago

RishabhMalviya commented 3 years ago

Environment data

Expected behaviour

The Python Interpreter should be picked up from the "python.pythonPath" key in settings.json.

Also, one should be able to specify multiple paths in the "python.pythonPath" in settings.json. In particular, I would like to point to:

  1. The Python3 installation in the Docker image
  2. The root folder of the project I am working on

This is to ensure linting and auto-complete to work properly:

{
    "python.pythonPath": "/usr/local/bin/python:${workspaceFolder}"
}

(In the case of multiple paths, the Python interpreter should be picked up from the first path.)

Actual behaviour

Every time I open VSCode or I try to run/debug my Python files, I am shown the following prompt: "You need to select a Python interpreter before you start debugging."

When I do so (selecting /usr/local/bin/python from the drop-down), it overwrites the settings.json file and removes the ${workspaceFolder}:

{
    "python.pythonPath": "/usr/local/bin/python"
}

This causes red linting to begin showing up in my code, because I am performing certain imports from the root of my working directory (and it has been removed from the settings.json).

Steps to reproduce:

  1. Clone this repository: https://github.com/RishabhMalviya/ml-productionization-template
  2. Put in any value for API_TOKEN in line 13 on the .env file:
    API_TOKEN=abracadabra
  3. Put in the absolute path to the repo root on your local machine in line 14. On my machine, that is:
    LOCAL_REPO_PATH=/c/Users/risha/giT/ml-productionization-template
  4. From the root of the repo, run docker-compose up -d model-dev. Wait for the container to come up.
  5. Open VSCode, make sure you have the Remote-Containers extension installed. From the command palette, choose "Remote-Containers: Attach to Running Container", and attach to the model-dev container you brought up in the previous step.
  6. Open the folder /app in the VSCode instance.
  7. A new VSCode window will open. Check if the Microsoft Python (ms-python.python) Extension is installed. If not, install it. You may also get a prompt to "install Linter pylint". Install it as well.
  8. Close the VSCode instance. Open it again.
  9. Open app.py and try to run it.
  10. After a minute or so, you'll get the following prompt from VSCode:
    No Python interpreter is selected. You need to select a Python interpreter to enable features such as IntelliSense, linting, and debugging.
  11. From the prompt, click Select Python Interpreter, and choose the interpreter Python 3.9.0 64-bit /usr/local/bin/python.
  12. Now there should be red lint under lines 9 and 10 in app.py, and there should be corresponding entries in the Problems panel on the bottom.
  13. Change the settings.json back to the original:
    {
    "python.pythonPath": "/usr/local/bin/python:${workspaceFolder}"
    }
  14. Try to run app.py again. You'll be forced to select a Python interpreter again.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` XXX ```

User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'ShowExtensionSurveyPrompt - enabled'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - experiment'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'LocalZMQKernel - experiment'
User belongs to experiment group 'CollectLSRequestTiming - control'
User belongs to experiment group 'CollectNodeLSRequestTiming - experiment'
User belongs to experiment group 'EnableIPyWidgets - experiment'
User belongs to experiment group 'RunByLine - experiment'
User belongs to experiment group 'CustomEditorSupport - control'
User belongs to experiment group 'pythonaacf'
Error 2020-11-22 07:18:47: Failed to check if file needs to be fixed [EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://attached-container+7b22636f6e7461696e65724e616d65223a222f6d6f64656c2d646576227d/root/.config/Code/User/settings.json' (EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/root/.config/Code/User/settings.json')
    at _handleError (/root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/out/vs/server/remoteExtensionHostProcess.js:754:838)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async y.readText (/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:9:152841)
    at async p.doesFileNeedToBeFixed (/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:469606)
    at async /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:468733
    at async Promise.all (index 0)
    at async p.getFilesToBeFixed (/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:468679)
    at async p.updateTestSettings (/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:468306)] {
  code: 'FileNotFound',
  name: 'EntryNotFound (FileSystemError)'
}
> pyenv root
> conda --version
> python2 ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.7 ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> conda info --json
Python interpreter path: /usr/local/bin/python
Starting Jedi Python language engine.
> conda --version
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.prefix)"
cwd: /app
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.prefix)"
cwd: /app
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
cwd: /app
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
cwd: /app
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: /app
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: /app
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py site --user-site
cwd: /app
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py site --user-site
cwd: /app
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text /app/app.py
cwd: /app
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text /app/app.py
cwd: /app
Error 2020-11-22 07:18:48: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

##########Linting Output - pylint##########
************* Module app
9,0,error,no-name-in-module:No name 'utils' in module 'api'
10,0,error,no-name-in-module:No name 'utils' in module 'api'
90,53,error,unsubscriptable-object:Value 'Union' is unsubscriptable

------------------------------------------------------------------
Your code has been rated at 7.27/10 (previous run: 7.27/10, +0.00)

Error 2020-11-22 07:20:19: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:20: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:34: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:37: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:38: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:40: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:42: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:44: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:45: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:47: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:48: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:50: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

Error 2020-11-22 07:21:51: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:592: DeprecationWarning: Providing the line is now done in the functions themselves like `Script(...).complete(line, column)`
  script = jedi.Script(
/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:592: DeprecationWarning: Providing the column is now done in the functions themselves like `Script(...).complete(line, column)`
  script = jedi.Script(

Error 2020-11-22 07:21:51: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:592: DeprecationWarning: Deprecated since version 0.17.0. Use the project API instead, which means Script(project=Project(dir, sys_path=sys_path)) instead.
  script = jedi.Script(

Error 2020-11-22 07:21:51: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:626: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).infer instead.
  script.goto_definitions(), request["id"]

Error 2020-11-22 07:21:51: stderr jediProxy Error (stderr) /root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/completion.py:584: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).get_names instead.
  jedi.api.names(

> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
Starting Jedi Python language engine.
Error 2020-11-22 07:22:53: Failed to create File hash for interpreter /usr/local/bin/python:/app [Error: ENOENT: no such file or directory, lstat '/usr/local/bin/python:/app'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/usr/local/bin/python:/app'
}
Error 2020-11-22 07:22:53: Failed to create File hash for interpreter /usr/local/bin/python:/app [Error: ENOENT: no such file or directory, lstat '/usr/local/bin/python:/app'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/usr/local/bin/python:/app'
}
Error 2020-11-22 07:22:53: Failed to create File hash for interpreter /usr/local/bin/python:/app [Error: ENOENT: no such file or directory, lstat '/usr/local/bin/python:/app'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/usr/local/bin/python:/app'
}
Error 2020-11-22 07:22:53: Failed to get interpreter information for '/usr/local/bin/python:/app' [Error: Command failed: "/usr/local/bin/python:/app" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/interpreterInfo.py"
/bin/sh: 1: /usr/local/bin/python:/app: not found

    at ChildProcess.exithandler (child_process.js:295:12)
    at ChildProcess.emit (events.js:223:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:430:11)
    at Socket.emit (events.js:223:5)
    at Pipe.<anonymous> (net.js:664:12)] {
  killed: false,
  code: 127,
  signal: null,
  cmd: '"/usr/local/bin/python:/app" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/interpreterInfo.py"'
}
Error 2020-11-22 07:22:53: Invalid Python Path '/usr/local/bin/python:/app'
Error 2020-11-22 07:22:53: Failed to get interpreter information for '/usr/local/bin/python:/app' [Error: Command failed: "/usr/local/bin/python:/app" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/interpreterInfo.py"
/bin/sh: 1: /usr/local/bin/python:/app: not found

    at ChildProcess.exithandler (child_process.js:295:12)
    at ChildProcess.emit (events.js:223:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:430:11)
    at Socket.emit (events.js:223:5)
    at Pipe.<anonymous> (net.js:664:12)] {
  killed: false,
  code: 127,
  signal: null,
  cmd: '"/usr/local/bin/python:/app" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/interpreterInfo.py"'
}
Error 2020-11-22 07:22:53: Invalid Python Path '/usr/local/bin/python:/app'
Error 2020-11-22 07:22:53: Failed to get interpreter information for '/usr/local/bin/python:/app' [Error: Command failed: "/usr/local/bin/python:/app" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/interpreterInfo.py"
/bin/sh: 1: /usr/local/bin/python:/app: not found

    at ChildProcess.exithandler (child_process.js:295:12)
    at ChildProcess.emit (events.js:223:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:430:11)
    at Socket.emit (events.js:223:5)
    at Pipe.<anonymous> (net.js:664:12)] {
  killed: false,
  code: 127,
  signal: null,
  cmd: '"/usr/local/bin/python:/app" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py" "/root/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/interpreterInfo.py"'
}
Error 2020-11-22 07:22:53: Invalid Python Path '/usr/local/bin/python:/app'
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text /app/app.py
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text /app/app.py
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import pylint"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import pylint"

Linter 'pylint' is not installed. Please install it or select another linter".
Error: spawn /usr/local/bin/python:/app ENOENT
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.prefix)"
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.prefix)"
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py site --user-site
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py site --user-site
cwd: /app
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python:/app ~/.vscode-server/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
hyperstown commented 3 years ago

Same problem here. I also tried to create a new project, initialize venv inside cwd and reopen folder and now I get the message:

image

I installed Code and Python extension inside VM to eliminate problem with my configuration and I get the same type of error. Although when I hit run it finds somehow path to python.

image


Environment data:

Version: 1.51.1 Date: 2020-11-12T10:54:25.653Z Electron: 9.3.4 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Linux x64 5.8.18-1-MANJARO Python: 3.8.6

ShadiestGoat commented 3 years ago

Also same here!

OS: Linux x64 5.9.8-arch1-1 Python: 3.8.6 VSC Version: 1.50.1 Electron: 9.3.4 Chrome: 83.0.4103.122 Node.js: 12.14.1

ShadiestGoat commented 3 years ago

ah also, looking at other issues & releases, according to a recent release, and issue #12462, this has been changed. I'm not quite sure about how this affects things, but it is a possibility.

kimadeline commented 3 years ago

Hello @RishabhMalviya and @ShadiestGoat, thank you for reaching out.

The python.pythonPath setting in settings.json only accepts the path to the Python interpreter, or the path to a folder containing the Python interpreter (settings reference).

If you want to specify extra paths like your workspace root, you should use the PYTHONPATH environment variable, which you can specify in a .env file, or via the OS-specific terminal.integrated.env.* setting (see this paragraph about the use of the PYTHONPATH environment variable).

RishabhMalviya commented 3 years ago

@kimadeline Thanks for the helpful reply.

As explained in the links you sent, I added the following to my .env file:

PYTHONPATH="/app:${env:PYTHONPATH}"

(I'm working inside a Docker container, and the absolute path /app is where all my code lives).

And following the steps taken by the OP in #12085, I added the terminal.integrated.env.* settings in my settings.json as follows:

{
    "python.pythonPath": "/usr/local/bin/python",
    "python.autoComplete.extraPaths": ["/app"],
    "terminal.integrated.env.linux": {
        "PYTHONPATH": "/app:${env:PYTHONPATH}"
    },
    "terminal.integrated.env.osx": {
        "PYTHONPATH": "/app:${env:PYTHONPATH}"
    },
    "terminal.integrated.env.windows": {
        "PYTHONPATH": "/app:${env:PYTHONPATH}"
    }
}

Auto-complete and debugging are working as expected now! But for some reason, the linter continues to insist that the imports from /app are incorrect. As a result, my Problems pane is almost always full.

Is linting not part of the core VSCode Python extension?

kimadeline commented 3 years ago

Hi @RishabhMalviya,

Linting is supported by the extension, although you'll have to install your own linter. Please open a separate issue since it is unrelated to what was initially reported, and specify there which linter you use as well.

Thanks!