Error unable to import frappe in VScode

Erpnext is working fine but when I use VScode as editor it gives error that ‘unable to import frappe’, it shows so many warnings and errors in the code, which is very distracting, is there a solution?

1 Like

You can select a particular Python environment when using VSCode.

You should select the one inside your bench path

3 Likes

I am using docker, so any solution for that? As frappe and bench resides in docker

I am not Docker or VSCode literate but this explains you have a setup choice -

  • You can use a container as your full-time development environment.
  • You can attach to a running container to inspect it.
1 Like

Hi,

Try adding frappe path to .vscode/settings.json

frappe path (mostly): ${workspaceFolder}/frappe-bench/apps/frappe

Add this line: "python.analysis.extraPaths": ["${workspaceFolder}/frappe-bench/apps/frappe"]

It is working for me.

Let me know if it works for you too.

1 Like

Open Command Prompt
image

Then in folder frappe-bench/env Find Python Executable and Select it and it will work

Required vscode Extensions

  1. Python - Visual Studio Marketplace
  2. Pylance - Visual Studio Marketplace

Thanks