skip to Main Content

I am using visual studio code on windows, and I am trying to run a python code on jupyter-notebook. I have all packages installed and they work fine when it is a normal python file. But I need it to run as a notebook. Once I run the block, I immediately get the following error:

ModuleNotFoundError                       Traceback (most recent call last)
~AppDataLocalTempipykernel_56681439934476.py in <module>
      1 import csv
----> 2 from pandas import read_csv
      3 from matplotlib import pyplot as plt
      4 import numpy as np
      5 import os

ModuleNotFoundError: No module named 'pandas'

I made sure that requirements are already satsified for this module, and I already tried running this line in python file with no issues. Therefore, how can I solve this issue? How can I let Jupyter notebook compiler to see where these packages actually are?

3

Answers


  1. First you need to install pandas by running the command in your console:

    pip install pandas
    

    If you don’t have pip installed on your computer then install it, otherwise you won’t be able to download pandas or other modules

    PS: check that when you downloaded python you chose the add to PATH option

    Hoping I could help

    Login or Signup to reply.
  2. The installation of pip is related to the python path specified in the environment variable. You need to select the correct interpreter in vscode.

    Python is an interpreted language, and in order to run Python code and get Python IntelliSense, you must tell VS Code which interpreter to use.

    From within VS Code, select a Python 3 interpreter by opening the Command Palette (Ctrl+Shift+P), start typing the Python: Select Interpreter command to search, then select the command. You can also use the Select Python Environment option on the Status Bar if available (it may already show a selected interpreter, too):
    enter image description here

    Read docs for more details.

    Login or Signup to reply.
  3. If you have a problem running jupyter notebook file make sure

    1. You have installed jupyter notebook from anaconda from this site
    2. Once you installed that, open anaconda navigator and click environment tab
    3. Install python and pandas

    Jupyter Notebook works like environment different from VSCode

    You can also run Jupyter Notebook file on VSCode by installing Jupyter extension in VSCode

    My guess is you don’t installed it yet in anaconda navigator, that’s what makes it error

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search