What to do when things go wrong#
First, have a look at the common problems listed below. If you can figure it outfrom these notes, it will be quicker than asking for help.
Check that you have the latest version of any packages that look relevant.Unfortunately it’s not always easy to figure out what packages are relevant,but if there was a bug that’s already been fixed,it’s easy to upgrade and get on with what you wanted to do.
Jupyter fails to start#
Have youinstalled it? ;-)
If you’re using a menu shortcut or Anaconda launcher to start it, tryopening a terminal or command prompt and running the command
jupyternotebook.If it can’t find
jupyter,you may need to configure yourPATHenvironment variable.If you don’t know what that means, and don’t want to find out,just (re)install Anaconda with the default settings,and it should set up PATH correctly.If Jupyter gives an error that it can’t find
notebook,check with pip or conda that thenotebookpackage is installed.Try running
jupyter-notebook(with a hyphen). This should normally be thesame asjupyternotebook(with a space), but if there’s any difference,the version with the hyphen is the ‘real’ launcher, and the other one wrapsthat.
Jupyter doesn’t load or doesn’t work in the browser#
Try in another browser (e.g. if you normally use Firefox, try with Chrome).This helps pin down where the problem is.
Try disabling any browser extensions and/or any Jupyter extensions you haveinstalled.
Some internet security software can interfere with Jupyter.If you have security software, try turning it off temporarily,and look in the settings for a more long-term solution.
In the address bar, try changing between
localhostand127.0.0.1.They should be the same, but in some cases it makes a difference.
Jupyter can’t start a kernel#
Files calledkernel specs tell Jupyter how to start different kinds of kernels.To see where these are on your system, runjupyterkernelspeclist:
$ jupyter kernelspec listAvailable kernels: python3 /home/takluyver/.local/lib/python3.6/site-packages/ipykernel/resources bash /home/takluyver/.local/share/jupyter/kernels/bash ir /home/takluyver/.local/share/jupyter/kernels/ir
There’s a special fallback for the Python kernel:if it doesn’t find a real kernelspec, but it can import theipykernel package,it provides a kernel which will run in the same Python environment as the notebook server.A path ending inipykernel/resources, like in the example above,is this default kernel.The default often does what you want,so if thepython3 kernelspec points somewhere elseand you can’t start a Python kernel,try deleting or renaming that kernelspec folder to expose the default.
If your problem is with another kernel, not the Python one we maintain,you may need to look for support about that kernel.
Python Environments#
Multiple python environments, whether based on Anaconda or Python Virtual environments,are often the source of reported issues. In many cases, these issues stem from theNotebook server running in one environment, while the kernel and/or its resources,derive from another environment. Indicators of this scenario include:
importstatements within code cells producingImportErrororModuleNotFoundexceptions.General kernel startup failures exhibited by nothing happening when attemptingto execute a cell.
In these situations, take a close look at your environment structure and ensure allpackages required by your notebook’s code are installed in the correct environment.If you need to run the kernel from different environments than your Notebookserver, check outIPython’s documentationfor using kernels from different environments as this is the recommended approach.Anaconda’snb_conda_kernelspackage might also be an option for you in these scenarios.
Another thing to check is thekernel.json file that will be located in theaforementionedkernel specs directory identified by runningjupyterkernelspeclist.This file will contain anargv stanza that includes the actual command to runwhen launching the kernel. Oftentimes, when reinstalling python environments, a previouskernel.json will reference an python executable from an old or non-existent location.As a result, it’s always a good idea when encountering kernel startup issues to validatetheargv stanza to ensure all file references exist and are appropriate.
Windows Systems#
Although Jupyter Notebook is primarily developed on the various flavors of the Unixoperating system it also supports MicrosoftWindows - which introduces its own set of commonly encountered issues,particularly in the areas of security, process management and lower-level libraries.
pywin32 Issues#
The primary package for interacting with Windows’ primitives ispywin32.
Issues surrounding the creation of the kernel’s communication file utilize
jupyter_core’ssecure_write()function. This function ensures a file iscreated in which only the owner of the file has access. If libraries likepywin32are not properly installed, issues can arise when it’s necessary to use the nativeWindows libraries.Here’s a portion of such a traceback:
File"c:\users\jovyan\python\myenv.venv\lib\site-packages\jupyter_core\paths.py",line424,insecure_writewin32_restrict_file_to_user(fname)File"c:\users\jovyan\python\myenv.venv\lib\site-packages\jupyter_core\paths.py",line359,inwin32_restrict_file_to_userimportwin32apiImportError:DLLloadfailed:Thespecifiedmodulecouldnotbefound.
As noted earlier, the installation of
pywin32can be problematic on Windowsconfigurations. When such an issue occurs, you may need to revisit how the environmentwas setup. Pay careful attention to whether you’re running the 32 or 64 bit versionsof Windows and be sure to install appropriate packages for that environment.Here’s a portion of such a traceback:
File"C:\Users\jovyan\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py",line435,insecure_writewin32_restrict_file_to_user(fname)File"C:\Users\jovyan\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py",line361,inwin32_restrict_file_to_userimportwin32apiImportError:DLLloadfailed:%1isnotavalidWin32application
Resolving pywin32 Issues#
In this case, your
pywin32module may not be installed correctly and the followingshould be attempted:pipinstall--upgradepywin32or:
condainstall--force-reinstallpywin32followed by:
python.exeScripts/pywin32_postinstall.py-installwhere
Scriptsis located in the active Python’s installation location.
Another common failure specific to Windows environments is the location of variouspython commands. On
*nixsystems, these typically reside in thebindirectoryof the active Python environment. However, on Windows, these tend to reside in theScriptsfolder - which is a sibling tobin. As a result, when encounteringkernel startup issues, again, check theargvstanza and verify it’s pointing to avalid file. You may find that it’s pointing inbinwhenScriptsis correct, orthe referenced file does not include its.exeextension - typically resulting inFileNotFoundErrorexceptions.
This Worked An Hour Ago#
The Jupyter stack is very complex and rightfully so, there’s a lot going on. On occasionyou might find the system working perfectly well, then, suddenly, you can’t get past acertain cell due toimport failures. In these situations, it’s best to ask yourselfif any new python files were added to your notebook development area.
These issues are usually evident by carefully analyzing the traceback produced inthe notebook error or the Notebook server’s command window. In these cases, you’ll typicallyfind the Python kernel code (fromIPython andipykernel) performingits importsand notice a file from your Notebook development error included in that traceback followedby anAttributeError:
File"C:\Users\jovyan\anaconda3\lib\site-packages\ipykernel\connect.py",line13,infromIPython.core.profiledirimportProfileDirFile"C:\Users\jovyan\anaconda3\lib\site-packages\IPython_init.py",line55,infrom.core.applicationimportApplication...File"C:\Users\jovyan\anaconda3\lib\site-packages\ipython_genutils\path.py",line13,inimportrandomFile"C:\Users\jovyan\Desktop\Notebooks\random.py",line4,inrand_set=random.sample(english_words_lower_set,12)AttributeError:module'random'hasnoattribute'sample'
What has happened is that you have named a file that conflicts with an installed packagethat is used by the kernel software and now introduces a conflict preventing thekernel’s startup.
Resolution: You’ll need to rename your file. A best practice would be to prefix ornamespace your files so as not to conflict with any python package.
Asking for help#
As with any problem, try searching to see if someone has already found an answer.If you can’t find an existing answer, you can ask questions at:
Peruse thejupyter/help repository on Github (read-only)
Or in an issue on another repository, if it’s clear which component isresponsible. Typical repositories include:
jupyter_core -
secure_write()and file path issuesjupyter_client - kernel managementissues found in Notebook server’s command window.
IPython andipykernel - kernel runtime issuestypically found in Notebook server’s command window and/or Notebook cell execution.
Gathering Information#
Should you find that your problem warrants that an issue be opened innotebook please don’t forget to provide detailslike the following:
What error messages do you see (within your notebook and, more importantly, inthe Notebook server’s command window)?
What platform are you on?
How did you install Jupyter?
What have you tried already?
Thejupytertroubleshoot command collects a lot of informationabout your installation, which can also be useful.
When providing textual information, it’s most helpful if you canscrape the contentsinto the issue rather than providing a screenshot. This enables others to selectpieces of that content so they can search more efficiently and try to help.
Remember that it’s not anyone’s job to help you.We want Jupyter to work for you,but we can’t always help everyone individually.