Python refactor: Sort imports does not work with setuptools 49.2
See original GitHub issueEnvironment data
- VS Code version: 1.47.0
- Extension version (available under the Extensions sidebar): 2020.6.91350
- OS and version: linux Ubuntu 20.04
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.2
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
- Relevant/affected Python packages and their versions: isort
- Value of the
python.languageServer
setting: Jedi
Expected behaviour
Calling “Python refactor: Sort imports” from command palette sorts import in active document
Actual behaviour
Nothing happens
Steps to reproduce:
- install setuptools >= 49.2 in workspace venv
- launch “Python refactor: Sort imports” from command palette
Logs
Devtools console:
Error: /home/me/work/proj/venv/lib/python3.8/site-packages/setuptools/distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
warnings.warn(
at i (/home/me/.vscode/extensions/ms-python.python-2020.6.91350/out/client/extension.js:1)
at Socket.<anonymous> (/home/me/.vscode/extensions/ms-python.python-2020.6.91350/out/client/extension.js:1)
at Socket.emit (events.js:203)
at addChunk (_stream_readable.js:295)
at readableAddChunk (_stream_readable.js:276)
at Socket.Readable.push (_stream_readable.js:210)
at Pipe.onStreamRead (internal/stream_base_commons.js:166)
$onExtensionRuntimeError @ workbench.desktop.main.js:sourcemap:4312
Output pane:
> ~/work/proj/venv/bin/python ~/.vscode/extensions/ms-python.python-2020.6.91350/pythonFiles/pyvsc-run-isolated.py ~/.vscode/extensions/ms-python.python-2020.6.91350/pythonFiles/sortImports.py - --diff
cwd: ~/work/proj
This warning comes from isort that is installed in venv, both versions 4.3.21 and 5.0.9 (latest) produce this warning. Downgrading setuptools to <49.2 makes “Sort imports” command to work ok again - and this warning disappears. I believe this should not behave this way since even with the warning isort exit code is 0.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:14
- Comments:20
Top Results From Across the Web
VS Code's "Sort Imports" fails with exception - Stack Overflow
I tried switching the Language Server, but it does not help. Steps to reproduce: Open a python script with multiple import lines in...
Read more >setuptools 5.6 - PyPI
Easily download, build, install, upgrade, and uninstall Python packages.
Read more >Changelog — Python 3.8.14 documentation
find_library() now works correctly on macOS 11 Big Sur even if Python is built on an older version of macOS. Previously, when built...
Read more >vscode isort config 11
... Sort imports does not work with setuptools 49.2 (, Python refactor: Sort imports does ... I was able to “fix” it by...
Read more >Bug listing with status RESOLVED with resolution OBSOLETE ...
Bug:1523 - "[IDEA] Offload work by distributing trivial ebuild maintenance to ... include order problem" status:RESOLVED resolution:OBSOLETE severity:normal ...
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 Free
Top 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
I ran into this problem.
I was able to “fix” it by editing
pythonFiles/sortImports.py
Removing
python.sortImports.path
fromsettings.json
fixed the issue for me