I am trying to run some Python code in Visual Studio Code. When I first save the file, say to fibonacci.py, I get a popup window that says,
Linter pylint is not installed.
It also displays three buttons: Install, Disable pylint, and Disable linting. If I click Install, I get the following error message:
$ /Users/me/.pyenv/versions/3.6.5/bin/python -m pip -U pylint
Could not find an activated virtualenv (required).
I can't see to get rid of this error message.
Here were the steps I took to set up my project:
- Installed the Python 3.6.5 interpreter:
pyenv install 3.6.5
. - Created a directory for the project.
- Changed to that directory and ran
pyenv local 3.6.5
to set the interpreter for that folder. This created a .python-version file containing the string "3.6.5" as expected. - Also created a virtualenv by running
pyenv virtualenv 3.6.5 py365
andpyenv activate py365
. - Opened the directory in VS Code:
code .
- From the Command Palette, I selected
Python: Select interpreter
and selected the interpreter for the folder that I set above in step 3. - From the Command Palette, I then ran
Python: Create Terminal
to open a terminal window.
It's at this point that if I create a new file and save it as fibonacci.py that I get the Linter message and the subsequent error message when I try to install the linter.
What's confusing to me is that the Code documentation Activate an environment in the Terminal talks about selecting an interpreter but then it seems to refer to the interpreter as an environment too. I thought that those are two different things, the interpreter being the Python interpreter and the environment the virtual environment where the packages you want to use for your project are installed. The doc goes on to say you should use "Python: Create Terminal" to automatically activate the environment, but I did that in step 7 above.
Furthermore, the next paragraph "Where the extension looks for environments" says one of the locations is "Interpreters installed by pyenv". But as I said above, I used pyenv to specify the 3.6.5 interpreter which created the .python-version file in the project folder. Isn't this what the document is talking about?
What am I not understanding?