# When Jupyter Notebooks Won't Import Libraries

DevFeed: [When Jupyter Notebooks Won't Import Libraries](<https://devfeed.tech/articles/when-jupyter-notebooks-won-t-import-libraries-28228.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/python/2020/01/03/when-jupyter-notebooks-won-t-import-libraries.html>)

Author: Fuzzygroup

Published: 2020-01-03T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Jupyter Notebook](<https://devfeed.tech/topics/jupyter-notebook.md>), [Python](<https://devfeed.tech/topics/python.md>), [Data Science](<https://devfeed.tech/topics/data-science.md>)

Tags: [data-science](<https://devfeed.tech/tags/data-science.md>), [execution](<https://devfeed.tech/tags/execution.md>), [flow](<https://devfeed.tech/tags/flow.md>), [installation](<https://devfeed.tech/tags/installation.md>), [jupyter](<https://devfeed.tech/tags/jupyter.md>), [jupyter-notebooks](<https://devfeed.tech/tags/jupyter-notebooks.md>), [kernel](<https://devfeed.tech/tags/kernel.md>), [python](<https://devfeed.tech/tags/python.md>)

## AI overview

An account of difficulties using Jupyter Notebooks with Python virtual environments. It discusses external data, dependency conflicts, attempts to change the Jupyter kernel, and the decision to convert the notebook into a Python script that can run in a virtual environment.

## Source excerpt

I don't claim to be an expert when it comes to Python. At best I'm an apprentice striving to be a journey man. One of the interesting tools in the Python / Data Science ecosystem is the Jupyter Notebook which gives a cell based representation of code, visualizations, documentation and execution flow and allows you to package things up for distribution i.e. hand your work, in a complete fashion, from say Data Scientist 1 ("Rebekah") to Data Scientist 2 ("Dawn"). This is a laudable goal and one that I theoretically agree with. Note: Jupyter Notebooks do NOT include data so that's still external to the notebook, something that can easily bite you (as it is currently biting me). I know a lot of pythonistas simply install libraries to their local machine and just have a collection of tools that the throw at problems. This, however, is a terrible practice due to code deprecation, version conflicts, etc. I say this with authority because I've been through this in the Ruby world before we all regularly started using Ruby virtual environments / Ruby version managers like RBENV / RVM which manage dependencies on a per project basis. Knowing this, my first practice with Python, is to always create a virtual environment, generally using Virtual ENV (VENV). So, when I set out today to use a Jupyter Notebook, my first approach was to make this work with a Jupyter Notebook. And, alas, I haven't been so lucky as to make this work cleanly with a Python virtual environment like VENV. Here are some of the things I tried: Installing jupyter into the virtual env and running from bin/jupyter notebook Following Angelo Basille's Directions Following Janakiev's Directions Changing the Kernel If you're curious about how to use Python Virtual Environments, I wrote a solid tutorial back in September that I used to get a full installation of Tensor Flow up and running. I've referred back to this over and over, each time I needed a Python Virtual Environment, so I know it works. I'm sure there i