vim-isort icon indicating copy to clipboard operation
vim-isort copied to clipboard

No Python Module Detected

Open jacobseiler opened this issue 6 years ago • 9 comments

Hi there,

I am getting the error No isort python module detected, you should install it. More info at https://github.com/fisadev/vim-isort when trying to execute isort within Vim. Isort has correctly been pip installed:

$ which isort
/Library/Frameworks/Python.framework/Versions/3.8/bin/isort

and isort example.py indeed does sort the imports.

Vim version is 8.1.

(Searched previous issues and none of the solutions worked. I have pip installed isort through both python3.8 and 2.7).

jacobseiler avatar Dec 17 '19 23:12 jacobseiler

Also occurs with NVIM v0.4.3

ajslater avatar Jan 13 '20 00:01 ajslater

Yup I'm getting this.

I had installed isort with pipx (which uses the same python3 interpreter that vim was built with) but I also tried setting up a virtual environment using python3 -m venv foo and activating it and installing isort using normal pip command but the plugin still thinks it can't find isort.

In the end I uninstalled the plugin and just added the following to my vim file:

autocmd BufWritePost *.py :!isort %

Integralist avatar Jan 23 '20 13:01 Integralist

For a homebrew install, remove roxma/python-support module and it will work again.

The issue appears to be the roxma/python-support module b0rking up the sys.path and removing the

/usr/local/lib/python3.7/site-packages

More sophisticated plugins, like black get around this by the plugin itself installing their dependancies in venvs and appending their special install path to sys.path on plugin load.

ajslater avatar Jan 27 '20 21:01 ajslater

I think this is related to using pyenv. Isort plugin seems to use system python on startup.

fx-kirin avatar Feb 19 '20 04:02 fx-kirin

I had a similar issue which vim-sort could not find isort even though it was installed globally and in the virtualenv.

I had to find the actual python binary vim was using and install it in there.

  1. in vim :py3 import sys; print(sys.path)

  2. navigate to that location and find the python binary, in my case: cd /usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/bin

  3. install isort using this binary ./python3.8 -m pip install isort

I am using pyenv and virtualenv which may have messed up my paths and for some reason vim-isort could not find the "correct" python version when using :py3 on the following line https://github.com/fisadev/vim-isort/blob/05d709d9086be8b344a29d45afe05fbc3a5eb179/ftplugin/python_vimisort.vim#L12

zsoobhan avatar May 26 '20 11:05 zsoobhan

I had the same issue that @zsoobhan described above but that solution didn't work for me because even the command :py3 was not working.

I manage it installing the neovim package into the virtualenv

pip install neovim

johangp avatar Jul 12 '21 13:07 johangp

On Mac M1, I was also getting this issue. This was my solution.

Check to see if under:

vim --version

python & python3 have + instead of -. If they have the -, just run:

brew install vim

adraper2 avatar Jan 19 '22 20:01 adraper2

I am running into this - I have neovim using its own virtualenv, which has isort installed. I can do :py3 import isort but if I run :Isort I get No isort python module detected, you should install it. More info at https://github.com/fisadev/vim-isort. I have done the same thing with black and can confirm that neovim is picking up the black I installed in the virtualenv.

aarchiba avatar May 24 '22 12:05 aarchiba