Failing to sort imports with `isort`
See original GitHub issue[coc.nvim] coc-pyright 1.1.164 with Pyright 1.1.165`
Workspace: /project
Using python from /project/venv/bin/python
[Info - 2:26:57 PM] Pyright language server 1.1.165 starting
[Info - 2:26:57 PM] Server root directory: /Users/user/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
[Info - 2:26:57 PM] No configuration file found.
[Info - 2:26:57 PM] No pyproject.toml file found.
[Info - 2:26:57 PM] Setting pythonPath for service "main": "/project/venv/bin/python"
[Warn - 2:26:57 PM] stubPath /project/typings is not a valid directory.
[Info - 2:26:57 PM] Assuming Python version 3.9
[Info - 2:26:57 PM] Assuming Python platform Darwin
[Info - 2:26:57 PM] Searching for source files
[Info - 2:26:57 PM] Auto-excluding /project/venv
[Info - 2:26:57 PM] Found 3 source files
########## isort Output ##########
Error from isort:
Traceback (most recent call last):
File "/Users/user/.config/coc/extensions/node_modules/coc-pyright/pythonFiles/sortImports.py", line 11, in <module>
import isort.main
ModuleNotFoundError: No module named 'isort'
########## isort Output ##########
Error from isort:
Traceback (most recent call last):
File "/Users/user/.config/coc/extensions/node_modules/coc-pyright/pythonFiles/sortImports.py", line 11, in <module>
import isort.main
ModuleNotFoundError: No module named 'isort'
########## isort Output ##########
Error from isort:
Traceback (most recent call last):
File "/Users/user/.config/coc/extensions/node_modules/coc-pyright/pythonFiles/sortImports.py", line 11, in <module>
import isort.main
ModuleNotFoundError: No module named 'isort'
Getting an error: [coc.nvim] Failed to format import by isort
when running :CocCommand python.sortImports
The error is not expected because isort
exists and works within the project’s virtual environment:
$ which isort
/project/venv/bin/isort
$ isort .
Fixing /project/main.py
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Sort Import fails with an exception traceback #14546 - GitHub
When I try to sort imports on a python script, it fails with the following traceback: Traceback (most recent call last): File ...
Read more >VS Code's "Sort Imports" fails with exception - Stack Overflow
Open a python script with multiple import lines in VS Code: import sys import os from pprint import pprint · Open command palette...
Read more >Exceptions - isort
__init__( f"isort was told to sort imports within code that contains syntax errors: " f"{file_path}." ) self.file_path = file_path class IntroducedSyntaxErrors( ...
Read more >Use isort to sort your Python module imports automatically
isort is a Python library to sort imports alphabetically, and automatically separated into sections and by type. Before we use isort to format...
Read more >Sorting imports with isort — Perfect Python - YouTube
Welcome to Perfect Python, the series where I show you how to take your code to the next level — perfection.In this episode...
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
@hexcowboy Please set the value of
python.sortImports.args
asarray
, not as “string”.Reopening because this issue is still persisting and I was able to reproduce it in a VM.
Reproduce:
neovim
andvim-plug
~/.config/init.vim
with the following contents:PlugInstall
coc-pyright
with:CocInstall coc-pyright
~/.config/nvim/coc-settings.json
:CocCommand python.sortImports