Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start PyLint from correct anaconda environment in Visual Studio Code

I'm trying to make PyLint automagically use correct conda environment inside vscode but still getting import errors: [pylint] E0401:Unable to import 'django', although:

  • I'm starting vscode from correct environment. [1]
  • I have installed Python extension. [2]
  • I have set correct python.path. [3]
like image 607
pkowalczyk Avatar asked Jul 13 '17 23:07

pkowalczyk


People also ask

How do I run a Pylint code in Visual Studio?

In Visual Studio, right-click a Python project in Solution Explorer and select Python and then Run PyLint: This command prompts you to install PyLint into your active environment if it's not already present.

How do you change environment in VS Code?

Select and activate an environment By default, the Python extension looks for and uses the first Python interpreter it finds in the system path. To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).


1 Answers

You have to install pylint in this conda environment.

  1. Activate given environment with activate env_name (Windows) or source activate env_name.

  2. Install pylint in this environment:

    conda install pylint # or 'pip install pylint'
    
  3. Finally, restart vscode.

Source: https://github.com/DonJayamanne/pythonVSCode/wiki/Troubleshooting-Linting

like image 53
pkowalczyk Avatar answered Sep 21 '22 19:09

pkowalczyk