pyenv / pyenv-virtualenv

a pyenv plugin to manage virtualenv (a.k.a. python-virtualenv)
MIT License
6.34k stars 401 forks source link

isort doesn't work in the Python plugin for VS Code when using pyenv specifically #364

Open soapergem opened 4 years ago

soapergem commented 4 years ago

I use pyenv to manage my Python installs and pyenv-virtualenv to manage all my virtual environments. Everything about this has been great until recently I came across the strangest bug. I use Microsoft's VS Code as my IDE with the Python plugin. If you install isort into your virtual environment, you can enable a plugin feature to automatically sort your import statements to comply with the PEP 8 guidelines every time you save a file.

What makes this strange is that this works when you use a conventional virtual environment, but it specifically does not work when pyenv-virtualenv is managing the virtual environment. In the latter case, a dialog box hangs indefinitely and the file is never saved. Something about running the Python extension for VS Code with isort configured to run on save chokes when isort is installed inside a virtual environment managed specifically by pyenv.

Here's the corresponding issue over in the vscode-python repo. Any ideas why this would be different with pyenv-virtualenv?

jimenezj8 commented 1 year ago

@soapergem are you sure you've installed isort into the active virtualenv while working in VSC? I've found that whenever I have issues running things like black and isort, it's because I haven't properly configured the interpreter in VSC or haven't installed the package into the appropriate virtualenv. In the former case, you can usually just specify the path /path/to/.pyenv/shims/bin/python.