I am new to python. I would like to create a Jupyter Notebook in a virtual environment in VS Code. I want to do different kind of projects because of that I have tried to create a virtual environment inside VS Code, where I can download the required packages for the project i.e. Tensorflow, PyTorch… And I want to do those projects in a Jupyter Notebook because I also would like to present them.
- First I created a folder in desktop.
Step 1 - I dragged the folder on VS Code window.
Step 2 - Created a Jupyter Notebook file called "Project1.ipynb"
Step 3 - Then Ctrl+Shift+P, and chose ">python:Create Environment" -> Type "venv" and the lates Python version that I have as interpreter
Step 4 - At last I moved the Jupyter Notebook file to ".venv" virtuasl environment.
enter image description here
- So my question is how can I pip install specific python packages to that virtual environment and use them just in that particular virtual environment and not globally ?
2
Answers
First: Activate the environment that you created.
like in conda, you can activate the environment as "conda activate venv"
Second: after activation you can just do pip install package-name.
enter image description here
Inside your Jupyter Notebook, you can run
%pip install numpy
in order to install a NumPy library.