"Organize Imports" does nothing
See original GitHub issueEnvironment data
- Language Server version: 2020.9.4
- OS and version: WSL2/Ubuntu 20.04.1 LTS
- Python version: 3.6.11
Expected behaviour
Running “Organise Imports” from the command palette invokes isort
and fixes import order
Actual behaviour
No change to file, no output
Logs
Pylance:
User belongs to experiment group 'AlwaysDisplayTestExplorer - experiment'
User belongs to experiment group 'ShowPlayIcon - start'
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 'AA_testing - experiment'
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 'pythonaa'
User belongs to experiment group 'pythonTipPromptWording'
> conda --version
> python3.7 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> conda info --json
Error 2020-09-16 14:20:24: Failed to check if file needs to be fixed [EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://wsl+ubuntu2/home/lex/.config/Code/User/settings.json' (EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/home/lex/.config/Code/User/settings.json')
at _handleError (/home/lex/.vscode-server/bin/e790b931385d72cf5669fcefc51cdf65990efa5d/out/vs/server/remoteExtensionHostProcess.js:730:74)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async v.readText (/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:1:495755)
at async p.doesFileNeedToBeFixed (/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:953520)
at async /home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:952647
at async Promise.all (index 0)
at async p.getFilesToBeFixed (/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:952593)
at async p.updateTestSettings (/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:952220)] {
code: 'FileNotFound',
name: 'EntryNotFound (FileSystemError)'
}
Error 2020-09-16 14:20:24: Failed to get interpreter information for '/home/lex/.pyenv/shims/python3.8' [Error: Command failed: "/home/lex/.pyenv/shims/python3.8" "/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py" "/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/interpreterInfo.py"
pyenv: python3.8: command not found
The `python3.8' command exists in these Python versions:
3.8.4
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be 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 Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)] {
killed: false,
code: 127,
signal: null,
cmd: '"/home/lex/.pyenv/shims/python3.8" "/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py" "/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/interpreterInfo.py"'
}
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import jupyter"
Starting Pylance language server.
Python interpreter path: ./.venv/bin/python3.6
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import notebook"
> conda --version
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
##########Linting Output - flake8##########
4,1,I,I004:isort found an unexpected blank line in imports
6,1,I,I001:isort found an import in the wrong position
7,1,I,I004:isort found an unexpected blank line in imports
8,101,E,E501:line too long (102 > 100 characters)
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/sortImports.py - --diff
cwd: ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/sortImports.py - --diff
cwd: ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/sortImports.py - --diff
cwd: ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/sortImports.py - --diff
cwd: ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py black --diff --quiet ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py black --diff --quiet ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
##########Linting Output - flake8##########
4,1,I,I004:isort found an unexpected blank line in imports
6,1,I,I001:isort found an import in the wrong position
7,1,I,I004:isort found an unexpected blank line in imports
8,101,E,E501:line too long (102 > 100 characters)
Microsoft (where it works):
User belongs to experiment group 'AlwaysDisplayTestExplorer - experiment'
User belongs to experiment group 'ShowPlayIcon - start'
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 'AA_testing - experiment'
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 'pythonaa'
User belongs to experiment group 'pythonTipPromptWording'
> conda --version
> conda info --json
> python3.7 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
Error 2020-09-16 14:22:45: Failed to check if file needs to be fixed [EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://wsl+ubuntu2/home/lex/.config/Code/User/settings.json' (EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/home/lex/.config/Code/User/settings.json')
at _handleError (/home/lex/.vscode-server/bin/e790b931385d72cf5669fcefc51cdf65990efa5d/out/vs/server/remoteExtensionHostProcess.js:730:74)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async v.readText (/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:1:495755)
at async p.doesFileNeedToBeFixed (/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:953520)
at async /home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:952647
at async Promise.all (index 0)
at async p.getFilesToBeFixed (/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:952593)
at async p.updateTestSettings (/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/out/client/extension.js:56:952220)] {
code: 'FileNotFound',
name: 'EntryNotFound (FileSystemError)'
}
Error 2020-09-16 14:22:45: Failed to get interpreter information for '/home/lex/.pyenv/shims/python3.8' [Error: Command failed: "/home/lex/.pyenv/shims/python3.8" "/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py" "/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/interpreterInfo.py"
pyenv: python3.8: command not found
The `python3.8' command exists in these Python versions:
3.8.4
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be 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 Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)] {
killed: false,
code: 127,
signal: null,
cmd: '"/home/lex/.pyenv/shims/python3.8" "/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py" "/home/lex/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/interpreterInfo.py"'
}
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import jupyter"
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py -c "import notebook"
Starting Microsoft Python language server.
Python interpreter path: ./.venv/bin/python3.6
> conda --version
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
##########Linting Output - flake8##########
4,1,I,I004:isort found an unexpected blank line in imports
6,1,I,I001:isort found an import in the wrong position
7,1,I,I004:isort found an unexpected blank line in imports
8,101,E,E501:line too long (102 > 100 characters)
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/sortImports.py - --diff
cwd: ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/sortImports.py - --diff
cwd: ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py black --diff --quiet ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py.782ed9ea092c1f1aad5ec65bfe1037d5.tmp
cwd: ~/projects/data-lake
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py black --diff --quiet ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py.782ed9ea092c1f1aad5ec65bfe1037d5.tmp
cwd: ~/projects/data-lake
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
> ~/projects/data-lake/.venv/bin/python3.6 ~/.vscode-server/extensions/ms-python.python-2020.8.109390/pythonFiles/pyvsc-run-isolated.py flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s ~/projects/data-lake/src/retailer_service_retailer_facts_compactor/tests/test_retailer_service_retailer_facts_compactor.py
cwd: ~/projects/data-lake
##########Linting Output - flake8##########
6,101,E,E501:line too long (102 > 100 characters)
Code Snippet / Additional information
from unittest.mock import Mock
import pytest
from pyspark.sql.session import SparkSession
from _pytest.monkeypatch import MonkeyPatch
from retailer_service_retailer_facts_compactor.glue.retailer_service_retailer_facts_compactor import (
main,
)
isort
exists, is installed in the virtualenv and is configured via pyproject.toml
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (1 by maintainers)
Top Results From Across the Web
Eclipse Organize Imports Shortcut (Ctrl+Shift+O) is not working
The Java Organize Import command is overwritten by another Ctrl + Shift + O command: in Window > Preferences: General > Keys the...
Read more >Auto import | IntelliJ IDEA Documentation - JetBrains
The Optimize Imports feature helps you remove unused imports and organize import statements in the current file or in all files in a...
Read more >560631 – "Remove unused imports" does not work (anymore)
In brief: Clean Up > Eclipse [built in] does NOT "Remove unused imports" is Save Actiopns > Organize imports is NOT checked! This...
Read more >How to organize imports with Metals and/or Scalafix - Reddit
Organize imports with Scalafix does not work for Scala 3. Any recommendations?
Read more >Hendrik Mans on Twitter: ""Organize Imports" appears to have ...
4.7.3 project. Same for anyone else? It's not the keyboard shortcut -- I can go through "Source Actions" -> "Organize Imports" and nothing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No worries!
The issue you’re encountering sounds very similar to https://github.com/microsoft/vscode-python/issues/13063, which is a duplicate of https://github.com/microsoft/vscode-python/issues/7042.
Can you try the workaround mentioned in #7042 by specifying the full path to isort to the setting:
"python.sortImports.path": "/home/username/project/.venv/bin/isort"
?"python.sortImports.path": "${workspaceFolder}/.venv/bin/isort"
works as well according to others.No problem, glad we’re getting it sorted out, and thank you for trying all the workarounds!
I opened a feature request on your behalf: https://github.com/microsoft/vscode-python/issues/14066, feel free to leave a comment there if you want to provide more details. You can also help us prioritize it by upvoting it 🙂
Going to close this issue and mark it as resolved, but if you encounter any problem later down the road let us know in the comments and we can reopen it.
Thank you!