Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code windows , Python Pandas . No module named pandas

I set the variables for Env. All necessary modules for Pandas operation are installed by pip. I wanted to run the code to display it in "Output". I run with: Alt + CTRL + N(or right click -> Run code).

enter image description here

In output returns the message:

enter image description here

But when I run in the terminal (right click -> Run Python File in Terminal), the code works correctly.

enter image description here

I would like the code to run correctly in output(right click -> Run code), not in the terminal. Any suggestions?

like image 468
Davdei Avatar asked Sep 18 '18 13:09

Davdei


3 Answers

I had a similar problem in VS Code. I was not able to find modules like Pandas, Selenium etc. Imports were underlined with a red colour.

Fixed the issue by changing the version of Python 3.7.3 64-bit to version 3.8.1 64-bit.

Procedure:

  1. Hit Ctrl + Shift + P
  2. Select Python: Select Interpreter
  3. Choose the latest installed version of Python (no more red underlines)
like image 110
Martin Avatar answered Nov 12 '22 04:11

Martin


@Davdei It is good practice to work with a virtual environment, so you can test against different versions of Python. To get the list of available Python interpreter use (⇧⌘P) on Mac or alternatively, you can click the status bar click the status bar

like image 8
Feras Avatar answered Nov 12 '22 04:11

Feras


It seems that the module pandas is installed in a virtual envorinment which you are not accessing via VS Code.

I'd suggest you to install pandas in default python as well via

pip install pandas

This way the VS Code will work it out just fine.

Else:

In VS Code console, activate the virtual enviornment in which you have installed the pandas module, and then run it. It should work

like image 6
Mohammad Zain Abbas Avatar answered Nov 12 '22 04:11

Mohammad Zain Abbas