最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - VS Code Problem: "Import "pandas" could not be resolved from source" - Stack Overfl

programmeradmin8浏览0评论

I am running a virtual environment for my project in VS code, and installed pandas and PyMuPDF but I cannot fix the flagged problems below. Please note that I am using a WSL command terminal with a Windows OS.

  • "Import "pandas" could not be resolved from source Pylance(reportMissingImports)"
  • "Import "pymupdf" could not be resolved Pylance(reportMissingImports)"

I've looked at prior stackoverflow threads, but the suggestions have not been able to fix this issue. I made sure that my packages are installed properly (see screenshot). My installed panadas version is 2.2.3 and my python version is 3.12.3 in the virtual environment.

This leads me to believe that I do not have the correct Python interpreter selected, but when I browse my file system to select a different interpreter in the venv/bin folder, it's empty so I cannot select a python interpreter. However, when I run "ls venv/vin", it shows that there are several Python interpreters installed (see screenshot).

I tried manually adding a path to my settings.json file to the Python interpreter, but that did not work either.

I do not know what to do from this point. If someone could please help, that would be much appreciated!

I am running a virtual environment for my project in VS code, and installed pandas and PyMuPDF but I cannot fix the flagged problems below. Please note that I am using a WSL command terminal with a Windows OS.

  • "Import "pandas" could not be resolved from source Pylance(reportMissingImports)"
  • "Import "pymupdf" could not be resolved Pylance(reportMissingImports)"

I've looked at prior stackoverflow threads, but the suggestions have not been able to fix this issue. I made sure that my packages are installed properly (see screenshot). My installed panadas version is 2.2.3 and my python version is 3.12.3 in the virtual environment.

This leads me to believe that I do not have the correct Python interpreter selected, but when I browse my file system to select a different interpreter in the venv/bin folder, it's empty so I cannot select a python interpreter. However, when I run "ls venv/vin", it shows that there are several Python interpreters installed (see screenshot).

I tried manually adding a path to my settings.json file to the Python interpreter, but that did not work either.

I do not know what to do from this point. If someone could please help, that would be much appreciated!

Share Improve this question edited Jan 20 at 14:18 NateDhaliwal 1431 silver badge12 bronze badges asked Jan 18 at 8:55 NikNik 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The simplest way to solve this is to create a new virtual environment, VScode usually recognizes that a new venv has been created and allows you to switch to that new environment.

in your vscode terminal, run rm -r {your env folder}, then python venv .venv (the name should be ".venv", sometimes it helps vscode recognize that this is a venv). You should receive a small modal at the bottom right of the screen for switching to the new environment. If you don't receive it, use source ./.venv/Scripts/Activate.

If all of this doesn't work, try running wsl code . to open vscode using wsl. It's very much possible that vscode is looking for a windows venv and fails to find a linux venv.

发布评论

评论列表(0)

  1. 暂无评论