Ethan Chaney
Ethan Chaney

Reputation: 31

How can you connect a jupyter notebook to a pipenv virtual environment using vscode?

I'm working on a project and was trying to set up a jupyter notebook to have access to the virtual environment. I set up the virtual environment just using pipenv install pandas, and that created the pipfile and the pip lock file. I then imported pandas in the jupyter notebook and tried printing out the version number, and got a ModuleNotFoundError: No module named 'pandas' error, meaning that the notebook is not connected to the virtual environment. I'm editing jupyter notebooks in vscode, and was wondering how I could connect the notebook to the pipenv environment?

Upvotes: 3

Views: 2089

Answers (1)

Jill Cheng
Jill Cheng

Reputation: 10354

Regarding using a virtual environment in Jyputer in VS Code and checking the python modules in this environment, you could refer to the following:

  1. Please make sure that the upper right corner of Jupyter is using the python environment you need.

  2. Please use "pip show pandas" to check whether the module "pandas" has been installed in the current environment.

In addition, since the python environment used by Jupyter in VS Code can be different from the environment used by VS Code, please check the selection of the relevant environment, and check the python environment currently used when installing the module on the VS Code terminal. (python --version or pip --version)

enter image description here

Reference: Python environments and Jupyter in VS Code.

Upvotes: 2

Related Questions