DEV Community

pacdev
pacdev

Posted on • Edited on

3

Jupyter notebook & environnement virtuel

đź‘‹ Pour tous mes projets python, je travaille avec un environnement virtuel. C'est assez simple Ă  mettre en place:

>> mkdir my_project
>> cd my_project
>> python3 -m venv venv
>> source venv/bin/activate
(venv) >>  pip install pandas
Enter fullscreen mode Exit fullscreen mode

Une fois venv activé 👌, toutes les commandes pip installeront les lib dans cet env.

Si on travaille parfois avec Jupyter Notebook on veut pouvoir utiliser notre environnement virtuel. Il suffit 🤷‍♂️ de faire:

(venv) >> pip install ipykernel
(venv) >> ipython kernel install --user --name=myproject
(venv) >> jupyter lab
Enter fullscreen mode Exit fullscreen mode

Lorsqu'on ouvrira un prochain notebook, on peut choisir le nouvel environnement créé et renommé ici my_project

venv dans jupyter


une commande que j'oublie souvent pour générer le fichier de config de jupyter
jupyter notebook --generate-config

⛵️

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

đź‘‹ Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay