Tag Archives: Jupyter Notebook

[Solved] Jupiter notebook failed to start Error: DLL load failed


1. Check whether it is in the virtual environment

If you start the python virtual environment and run Jupiter notebook on the command line of the virtual environment, the above DLL load failed error will appear

So when you want to start Jupiter notebook in a virtual environment. First use PIP install Jupiter in a virtual environment

2. Check the configuration environment variables

Add the following two paths to the environment variable

[Solved] Jupyter notebook Startup Crash Error in Tensorflow Environment: ssl.SSLError: Unknow error (_ssl.c:4034)

I tried many methods and saw an explanation on the Internet. I think it should be the python version, so I upgraded the python version in Anaconda navigator. Then enter in Anaconda prompt

You can successfully open the Jupiter notebook page

Here’s how to upgrade Python

Modify the default open file path of Jupiter notebook

1. Add jupyter_ notebook_ Config.py configuration file

·For Windows systems, open Anaconda prompt and enter the following command:

jupyter notebook --generate-config

After executing the command, it will generate a file named Jupiter_ notebook_ Config. Py

At the same time, the window will display the path of the configuration file, such as C: \ users \ user \. Jupyter \ jupyter_ notebook_ config.py

·For Linux system, open the terminal and directly enter the following commands

jupyter notebook --generate-config

After executing the command, it will generate a file named Jupiter_ notebook_ Config. Py

At the same time, the window will display the path of the configuration file, such as /home/user /. Jupyter/jupyter_ notebook_ config.py

2. Modify jupyter_ notebook_ Config.py configuration file

Open the file Jupiter according to the file path above_ notebook_ config.py

Find this line:


Add the file path you want in ” and remove #, for example:


Finally, create this folder under the corresponding file path, otherwise an error will be reported when opening Jupiter notebook.

The process of installing jupyter notebook on MAC

Don’t panic in case of data tilt, teach you to easily obtain the slope of table tilt>>>

Mac desktop

python:mac Comes with Python 2.7.10

1. Upgrade the PIP installation tool: sudo Python – M PIP install — Upgrade — force pip

2. Install setup tools: sudo PIP install setup tools = = 33.1.1

3. Install Python- dateutil:sudo pip install python-dateutil==2.2

4. Installation six:sudo pip install –ignore-installed six

5. Install jupyter: sudo install jupyter

Start command: input Jupiter notebook directly in the terminal

It took me a long time to do a good job. The above commands are used when there are various problems during installation. Write down the problems and corresponding solutions below

1.ImportError: cannot import name _ Thread report this error solution:

sudo pip uninstall python-dateutil
sudo pip install python-dateutil==2.2

2.File “/Library/Python/2.7/site-packages/dateutil/tz/_ common.py”, line 2, in < module>

from six.moves import _ thread
ImportError: cannot import name _ thread

Solution: install the six command again

After solving the above problem, an error will still be reported when starting. This is a stubborn error

File “/Library/Python/2.7/site-packages/packaging/requirements.py”, line 59, in < module>

MARKER_ EXPR = originalTextFor(MARKER_ EXPR())(“marker”)

TypeError: __ call__() takes exactly 2 arguments (1 given)

Solution: find the file in the path directly according to the error information, open the file and modify the function in line 59

59:#MARKER_ EXPR = originalTextFor(MARKER_ EXPR())(“marker”)
60:MARKER_ EXPR = originalTextFor(MARKER_ EXPR(“marker”))

After modification, directly save the file and run the jupyter notebook command again to start jupyter

As for the problem of sixs, we need to delete the sixs in our default path. Otherwise, even if the update is successful, the latest sixs will not be used

Method: first check the default six path

import six

print six.__ file__

Then delete: sudo RM - RF/system/library/frameworks/python. Framework/versions/2.7/extras/lib/python/six

Finally, use the above command to install and update the six

To solve the importerror: Matplotlib is required for plotting problem in Jupiter notebook

Don’t panic in case of data tilt, teach you to easily obtain the slope of table tilt>>>

solve the importerror: Matplotlib is required for plotting problem encountered in jupyter notebook

Reference article:

(1) To solve the importerror: Matplotlib is required for plotting problem in Jupiter notebook

(2) https://www.cnblogs.com/star-zhao/p/9726212.html

Let’s make a note.

NameError: name ‘true’ is not defined when opening ipynb file in jupyter notebook

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

Error in opening ipynb file in jupyter Notebook:

File "e:\python36\lib\site-packages\traitlets\config\loader.py", line 457, in load_config
  File "e:\python36\lib\site-packages\traitlets\config\loader.py", line 489, in _read_file_as_dict
    py3compat.execfile(conf_filename, namespace)
  File "e:\python36\lib\site-packages\ipython_genutils\py3compat.py", line 198, in execfile
    exec(compiler(f.read(), fname, 'exec'), glob, loc)
  File "C:\Users\xiaoqiu\.ipython\profile_default\ipython_config.py", line 513, in <module>
    c.Completer.greedy = true
NameError: name 'true' is not defined


After executing the IPython profile create command (to activate the automatic completion function), C:: (users/Xiaoqiu). IPython profile_ Default generates two files

IPython needs to be modified_ The config. Py file is modified with the following three parameters

jupyter notebook error: No module named ‘tensorflow’

When we run in jupyter notebook, we may encounter the situation that there is no certain package, as follows:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-24005895b065> in <module>
      2 import h5py 3 import matplotlib.pyplot as plt ----> 4 import tensorflow as tf 5 from tensorflow.python.framework import ops 6 import tf_utils ModuleNotFoundError: No module named 'tensorflow'

First of all, my jupyter notebook runs under the local environment of deep learning in Python 3

userdeMacBook-Pro:~ user$ conda activate deeplearning
(deeplearning) userdeMacBook-Pro:~ user$ jupyter notebook

But it’s strange that I have installed tensorflow in my python3 environment, but it still doesn’t appear in jupyter

(deeplearning) userdeMBP:~ user$ python
Python 3.7.2 (default, Dec 29 2018, 00:00:04) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow >>> tensorflow.__version__ '1.13.1' >>> 

It can be seen that tensorflow version 1.13.1 is installed

The solutions are as follows:

Open your anacondanavigator, select it according to the figure below, and then apply to install it

I made a mistake:

UnsatisfiableError: The following specifications were found to be in conflic
tensorflow == 1.11.0
use conda info <package> to check dependencies

After using CONDA info tensorflow to view the dependencies, it is found that tensorflow & lt= Python 3.7 is not supported in version 1.12.0, and the highest version of tensorflow provided in Anaconda navigator is 1.12.0, so I reduced it to version 3.6, that is, running under the specified environment of deep learning

(deeplearning) userdeMBP:~ user$ conda install python=3.6

Of course, this may lead to the loss of some previously installed packages, because when you import tensorflow again, you can see that the previously installed tensorflow is gone

(deeplearning) userdeMBP:~ user$ python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'

After that, you can see that the installation is successful

Then look at:

(deeplearning) userdeMBP:~ user$ python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> tensorflow.__version__

It can be seen that tensorflow = = 1.12.0 is successfully installed in the corresponding environment deep learning

If there is still unsatisfiable error in the process, in addition to the dependency problem, you can also try:

userdeMBP:~ user$ conda update conda


Error in importing tensorflow in Jupiter Notebook: no module named tensorflow solution

1. Background

First of all, my environment:

os : windows10

The official website provides two ways to install TensorFlow: PIP and anaconda. I use the anaconda method. After the installation is completed, you can import TensorFlow or run the program on the command line. Then I use the command Jupiter notebook to start Jupiter notebook in the created environment named TensorFlow. However, there is only python2 in the options of Jupiter notebook, and there is no newly installed environment, As shown in the following figure:

and when Import tensorflow as TF is executed, an error will occur: no module named TensorFlow

2. Solutions

Enter the anaconda command line, and then select TensorFlow environment:

> activate tensorflow

Execute the following command:

> conda install nb_conda

After the installation, start jupyter Notebook:

> jupyter notebook

At this time, you can see that the options for creating a file include our established environment TensorFlow


If you select TensorFlow environment and then Import tensorflow as TF , no error will occur


[Python Debug]Kernel Crash While Running Neural Network with Keras|Jupyter Notebook Run Keras Server Down

Recently, I did my machine learning assignment, and I want to build a neural network with keras on jupyter notebook. As a result, even the simplest layer of neural network couldn’t work. What’s more strange is that I ran the iris data set first, and there was no problem, but I used the fashion MNIST given by my teacher to prompt the server to hang up and restart as soon as I ran it. What’s more strange is that there’s no problem with the same code running on the students’ computers, which makes me think that my MacBook is too old and the configuration is too low, so I almost want to buy a new computer & gt_& lt;

After several times of debugging by ml teacher in class today, the problem has been solved perfectly, worthy of CMU God( Call Prof strongly here, though he doesn’t understand Chinese & gt& lt;) Because I haven’t learned Python for a long time and I’m not familiar with it. After this time, I’ve learned many new skills ✌️

The complete code of the problem is as follows, which is to use keras to realize logistic region. It is a simple one layer network, but every time it runs to the last line, the server will hang up, and then restart kernel

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA, FastICA
from sklearn.linear_model import LogisticRegression
from keras.models import Sequential
from keras.layers import Dense, Activation, Conv2D
from keras.utils import to_categorical
from keras.datasets import fashion_mnist

(x3_train, y_train), (x3_test, y_test) = fashion_mnist.load_data()
n_classes = np.max(y_train) + 1

# Vectorize image arrays, since most methods expect this format
x_train = x3_train.reshape(x3_train.shape[0], np.prod(x3_train.shape[1:]))
x_test = x3_test.reshape(x3_test.shape[0], np.prod(x3_test.shape[1:]))

# Binary vector representation of targets (for one-hot or multinomial output networks)
y3_train = to_categorical(y_train)
y3_test = to_categorical(y_test)

from sklearn import preprocessing
scaler = preprocessing.StandardScaler()
x_train_scaled = scaler.fit_transform(x_train)     
x_test_scaled = scaler.fit_transform(x_test) 

n_output = y3_train.shape[1]
n_input = x_train_scaled.shape[1]

nn_lr = Sequential() 
nn_lr.add(Dense(units=n_output, input_dim= n_input, activation = 'softmax'))
nn_lr.compile(optimizer = 'sgd', loss = 'categorical_crossentropy', metrics = ['accuracy'])

Since Jupyter Notebook just keeps restarting the kernel and there is no error message, so people can’t get started. But after the teacher prompted the original Jupyter Notebook automatically opened when the terminal will record information on the run (the first time a white person found.) The following is the detailed process of kerter abort and restart and the reasons for it.

[I 22:11:54.603 NotebookApp] Kernel interrupted: 7e7f6646-97b0-4ec7-951c-1dce783f60c4

[I 22:13:49.160 NotebookApp] Saving file at /Documents/[Rutgers]Study/2019Spring/MACHINE LEARNING W APPLCTN LARGE DATASET/hw/Untitled1.ipynb

2019-03-28 22:13:49.829246: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA

2019-03-28 22:13:49.829534: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 4. Tune using inter_op_parallelism_threads for best performance.

OMP: Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized.

OMP: Hint: This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.

[I 22:13:51.049 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports

kernel c1114f5a-3829-432f-a26a-c2db6c330352 restarted

There is another way to get a similar message by copying the code into ipython, so the final error located is

OMP: Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized.

Google it, there is a very detailed discussion post on github, but the owner was running XGBoost when he encountered this problem, which reminds me that the winter break installation of XGBoost did go through a very tortuous process, and may have accidentally downloaded a file to a different path repeatedly, so the program loaded the package when there was a conflict. The post provides several possible causes and solutions.

1. uninstall clang-omp

brew uninstall libiomp clang-omp

as long as u got gcc v5 from brew it come with openmp

follow steps in:

Tried uninstalling xgboost and installing it again, then uninstalling clang-omp, got an error

No such keg: /usr/local/Cellar/libiomp

pip uninstall xbgoost
pip install xgboost
brew uninstall libiomp clang-omp

2. Run directly in jupyter notebook

import os

The teacher said that this command allows the system to ignore the problem of package conflict and choose a package to use. Try this method is really effective, but it is very dangerous, extremely not recommended

3. Find the duplicate libiomp5.dylib file and delete one of them

Two files are found in finder, which are in ~/⁨ anaconda3 ⁩/lib ⁩ and ~/anaconda3 ⁩/⁨ lib ⁩/⁨ Python 3.6 ⁩/⁨ site packages ⁩/⁨_ solib_ darwin⁩/⁨_ U@mkl_ Udarwin_ S_ S_ Cmkl_ Ulibs_ Udarwin___ Uexternal_ Smkl_ Udarwin_ Slib⁩ (????) But I’m not sure which one should be deleted. I think it’s dangerous. I can’t run if I delete the wrong one

4. OpenMP conflict

Hint: This means that multiple copies of the OpenMP runtime have been linked into the program

According to hint in the prompt message, I searched tensorflow OpenMP. OpenMP is a multi thread parallel programming platform, tensorflow seems to have its own parallel computing architecture, and can not use OpenMP (see) https://github.com/tensorflow/tensorflow/issues/12434 )

5. Unload nomkl

I had the same error on my Mac with a python program using numpy, keras, and matplotlib. I solved it with ‘conda install nomkl’.

This is the last effective way! The full name of nomkl is math kernel library (MKL) optimization. It is a module developed by Interl to speed up mathematical operations. MKL can be used automatically by installing package through CONDA. For more details, please refer to the official document of anaconda

To opt out, runcondainstallnomkland then usecondainstallto install packages that would normally include MKL or depend on packages that include MKL, such asscipy,numpy, andpandas.

Maybe there are some conflicts in the update of package such as numpy. After installing nomkl, it was solved miraculously. Later, it tried to unload MKL, and the program is still running normally.. The unload command is as follows:

conda remove mkl mkl-service