Dylan Kaufman
Dylan Kaufman

Reputation: 98

Pandas not found in Visual Studio Code even though it is definitely in the env

I am running Visual Studio Code on two machines, both set up essentially the same way. One is an iMac, the other a MacBook Air. In one of my projects, on the iMac, it doesn't recognize that pandas is installed, even though it is in the environment.

Here is the VSC python interpreter selection:

enter image description here

And here you can see that:

  1. it is not able to import pandas
  2. I'm in the env
  3. pip3 freeze shows pandas
  4. pip3 install indicates that pandas is already present

enter image description here

I've tried uninstalling pandas and reinstalling it, but that doesn't help. I've tried making sure it's in the non-env python install (it is), but that doesn't help.

I have other projects on the same computer set up essentially the same way, and pandas works fine. I also have the same project on my laptop, with the same setup, and it is working there too. I'm kinda stumped. I guess I'll be working on it on the laptop for now, but I'd appreciate any insight people may have...

Edits

import pip

pip.main(["freeze"])

Thank you! Dylan

Upvotes: 1

Views: 3262

Answers (1)

Jill Cheng
Jill Cheng

Reputation: 10354

According to your description, it is command that you could refer to the following steps:

  1. Enter the current virtual environment in VSCode.

  2. Enter 'pip --version ' to check if the pip currently used is from the current environment: (This ensures that using pip to install pandas module will be put into the current virtual environment.)

enter image description here

  1. List of pips before installing pandas module: (There is no module pandas in the list.)

enter image description here

After installation:(I use the command 'pip install pandas'(windows10), mac: pip3 install pandas)

enter image description here

  1. If it still has wavy lines, try reloading vscode.(Ctrl+Shift+p, Developer: Reload windows ). The module pandas can be used:

    enter image description here

  2. Check the installation package:

    If the pip list shows the pands module, but we still can't use it, we can find the current virtual environment folder and check whether there is pandas installation package:

    enter image description here

Upvotes: 1

Related Questions