skip to Main Content

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.

  1. First I created a folder in desktop.
    Step 1
  2. I dragged the folder on VS Code window.
    Step 2
  3. Created a Jupyter Notebook file called "Project1.ipynb"
    Step 3
  4. Then Ctrl+Shift+P, and chose ">python:Create Environment" -> Type "venv" and the lates Python version that I have as interpreter
    Step 4
  5. 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


  1. 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

    Login or Signup to reply.
  2. Inside your Jupyter Notebook, you can run %pip install numpy in order to install a NumPy library.

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