Home > database >  VS Code - No module named 'streamlit'
VS Code - No module named 'streamlit'

Time:08-30

I am trying to use VS Code and I am importing some modules (for example : pandas and streamlit). The terminal of VS Code tells me "No module named pandas" or "No module named streamlit" whereas it is downloaded on my computer.

VS Code:

enter image description here

Terminal of my computer when trying "pip install streamlit":

enter image description here

Do you know how I could correct this mistake ?

CodePudding user response:

You are in a different env, so before you can import, you will have to append the path of the installed packages to your working environment.

import sys
sys.path.append("/opt/anaconda3/lib/python3.9/site-packages")

import streamlit as st

CodePudding user response:

Please ensure that the environment is consistent. pip installs the library into the real Python environment, and you use the virtual environment.

  1. If you want to use it in the virtual environment, please use the command conda install to install it.
  2. If you want to use the real python environment, you can use shortcuts "Ctrl shift P" and type "Python: Select Interpreter" to change the python environment.
  • Related