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
pytorch
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__
'1.12.0'
>>>
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
updated