You run the following command, by specifying the name of the virtual env you want to connect to Jupyter: python -m ipykernel install -name=my_virtual_env Now you can tell Jupyter where to find the virtual env. Thus, you activate your virtual env and then from your virtual env you run this command: pip install ipykernel Firstly, you need to install the ipykernel in your virtual env. To exit (deactivate) the virtual env, simply run the following command: deactivate Running a Virtual Env from Jupyter NotebookĪ virtual env can be also used in Jupyter. ![]() The list of all your installed libraries also permits to quickly write down the libraries required for your project. ![]() You can see the virtual env name in the left part of your terminal line, as follows: (my_virtual_env) my_pc:Ī very useful function is listing all the libraries of your virtual env: pip list -local ![]() You can activate your virtual env by terminal, simply entering the virtual env directory and running the source command: cd my_virtual_env source bin/activate Usually, a new virtual env is clean, in the sense that it does not contain any global library. Where my_virtual_env can be any name you want. Once created the directory, you access it and you create the virtual env simply running the following command virtualenv my_virtual_env Then, you can create a directory, where you will store all your virtual environments. For example, this can be done in pip through the following command: pip install virtualenv Installing and Running a Virtual Envįirstly, you need to install the virtualenv package. How to solve this problem? Virtualenv may help.Ī Python virtualenv is a standalone Python environment, where you can install only the packages that you need for your project. ![]() And it may happen that, in different projects, libraries conflict.įor example, it may happen that two different projects require two different versions of the same library, so in a single Python environment, two versions of the same library cannot be installed. As the number of projects grows, so do the installed libraries. Usually, a beginner programmer starts to install all the needed libraries in the main Python environment.
0 Comments
Leave a Reply. |