jupyter ModuleNotFoundError: No module named Tensorflow or keras - python

I cannot seem to import Tensorflow or keras.
I have windows 10 computer
I have python 3.8.5
I installed the following using command pip3 install XXXXXXXXXX
1.matplotlib
2.pandas
3.numpy
4.Tensorflow
5.keras
in that order
i have no problem importing matplotlib, pandas or numpy.
but when I try to import tensorflow or keras, it cannot find the module (see screenshot provided)
i also checked in cmd to ensure i have them installed (see screenshot)
FYI, I installed python in drive F: and windows is installed in drive C:
is there a reason why I can import pandas, and not tensorflow or keras?
any form of help would be highly appreciated!
screenshot on jupyter error:

what version of tensorflow do you want to install? My experience is to use Anaconda onda terminal to install tensorflow. First install tensorflow 2.1 using conda.Conda automatically installs cudnn 7.6.5 and CUDA Toolkit 10.1.243. These are compatible with tensorflow 2.2. Then use pip to install tensorflow 2.2 as shown below
pip install tensorflow ==2.2.0
Conda at this time can only install tensorflow up to 2.1 that is why you have to use pip. pip does not automatically install cudnn or the Cuda toolkit but you already have them installed when you install version 2.1 with Conda. Otherwise you would have to go through a more complicated process to manually install cudnn and the toolkit. Some people have reported problems using python 3.8 with tensorflow. If you run into that create as seperate environment and install python 3.7, tensorflow 2.1 using conda, then install tensorflow 2.2 using pip.

Related

Cannot install TensorFlow 1.x

I am trying to install Tensorflow 1.14 for a package that I am trying to use. I tried:
pip3 uninstall tensorflow
Then I tried to install Tensorflow 1.14 using:
pip3 install tensorflow==1.14
and I get the following error
ERROR: Could not find a version that satisfies the requirement tensorflow==1.14 (from versions: 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2) ERROR: No matching distribution found for tensorflow==1.14
I also tried making a new virtual env and tried the following commands but it didn't work. Is there any way to install Tensorflow 1?
What I've found on discourse:
You just need to make sure you’re using Python 3.5, 3.6 or 3.7. TensorFlow 1.15 does not support Python 3.8
It works for me to install 1.x tensorflow with the following command:
pip3 install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.14.0-py3-none-any.whl
Try installing the final version of TensorFlow 1.15 using,
pip install tensorflow==1.15
Make sure that you are using a python3 virtual environment and Python version is 3.6 or above.
Or you may use Conda environment and install using
conda install -c conda-forge tensorflow=1.15
On top of what being said (i.e. the version), be sure that it is 64-bits version because Tensorflow is not working with Python 32 bits (or at least the recent versions).
You can check your version by typing python in the command line and check what appears.
For example, this is for 32 bits
and for 64bits
I faced the same issue while installing tensorflow version 1.14.0. The best solution i tried is:
Note that your Python version is 3.7.8
Steps:
Open python 3.7.8 script folder C:\Users\mypc\AppData\Local\Programs\Python\Python37\Scripts folder and type "cmd" in above bar, which opens it in the command prompt.
To install tensorflow-1.14.0 type : pip install tensorflow==1.14.0
To install keras-2.2.4 type : pip install keras==2.2.4
From this issue on the Tensorflow Github titled Tensorflow 1.x not available for python 3.8:
Saduf2019: TensorFlow 1.x even 2.1 does not support Python 3.8
mihaimaruseac: We don't add new versions of Python for old releases. If you want to use TF 1.15, you have to use Python 3.7 or lower. If you want to use Python 3.8 you have to use TF 2.2 or newer.
Sounds like support for newer versions of Python > 3.7 won't be available for any tensorflow 1.x < 1.15.

tensorflow-gpu installation problem on system with multiple cuda versions

I installed tensorflow-gpu using
sudo pip3 install tensorflow-gpu on python3.6
The system I am using has both cuda 10 and cuda 9.0 installed on it.
I have exported the cuda 9.0 paths, but import tensorflow still gives me
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory
Is there any way I can force tensorflow to use cuda 9.0 because the default pre-compiled tensorflow using pip only works with cuda 9.0 according to the official documentation.
Additional info:
I do not want to use a virtualenv because I am installing tensorflow for the entire system so that all users can use it.
I have in the past installed tensorflow after compiling with bazel, but only I was able to use it. Other users could not, even after exporting the cuda paths to their profiles. So, I am trying to make the default pip installation work this time. I have uninstalled the previous tensorflow installation successfully.
try installing a different version of tensorflow like 1.11.0 i.e a version that supports cuda 9
To import tensorflow your environment should have numpy.So check numpy is installed or not using import numpy? If it is intalled then install tensorflow and tensorflow-gpu using following commands.
activate yourEnvName
conda install tensorflow
conda install tensorflow-gpu

Using TensorFlow backend. Error importing tensorflow

I've installed and imported tensorflow before (https://github.com/ankur715/MOOCs/blob/master/pythonprogramming/ds_tf_keras_tutorial.ipynb), but Anaconda on my Windows went haywire starting this week.
It wasn't loading the Jupyter localhost after several tries/times, so I uninstalled it and reinstalled it. Then realized that Python 3.7 is what didn't allow tensorflow. I downgraded to Python 3.5, checked version of tensorflow which is 0.12.0.
I think it wasn't working because of Python 3.7 earlier, and now tensorflow is 0.12.0. How do I upgrade to tensowflow 1.12.0, to see if that'll solve it?
It is better to remove and install:
conda uninstall tensorflow
conda install -c conda-forge tensorflow=1.12.0
Look here.

having a problem offline install tensorflow on windows

I am using Python 3.6 from Anaconda 4.3.1 on Windows 10. I'm trying to offline install TensorFlow, and i have download a .whl file to install module.
install tensorflow warning
But I have installed the tensorboard 1.12 moudule on my computer.
I have installed the tensorboard moudule
I have no way to install tensorflow now. please help me, thanks!
I have solved this problem. Tensorflow 1.11 need tensorboard version 1.11, but I have installed tensorboard 1.12.

Tensorflow install fails with "compiletime version 3.5 of module does not match runtime version 3.6"

I tried installing from pip:
pip3 install --user --no-cache https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.0-cp36-cp36m-linux_x86_64.whl
Then tried importing and got:
Using TensorFlow backend.
/usr/lib64/python3.6/importlib/_bootstrap.py:205: RuntimeWarning:
compiletime version 3.5 of module
'tensorflow.python.framework.fast_tensor_util' does not match runtime
version 3.6
return f(*args, **kwds)
2017-11-10 09:35:01.206112: I
tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports
instructions that this TensorFlow binary was not compiled to use: SSE4.1
SSE4.2 AVX
Questions:
I don't understand why the wheel says 3.6, but I get the warning about 3.5
I want to compile to optimize for my cpu, so can I use pip to install from source rather than from binary wheel?
RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
This is a known issue, which is got prioritized and likely to be fixed soon. Right now the workaround is to use python 3.5.
UPDATE:
The issue has been fixed in the nightly tensorflow builds: "tf-nightly and tf-nightly-gpu now has a python3.6 binary built from scratch for Linux."
I.e., the following command should work with python 3.6:
# tf-nightly or tf-nightly-gpu
pip3 install tf-nightly
Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
This warning comes from the fact that the default tensorflow distributions are compiled without CPU extensions support (more on this here). If you want to get a CPU optimized tensorflow package, your only option is to build it yourself. It's a bit tedious, but absolutely doable. The build will produce the wheel file, which you can install with just
pip3 install /path/to/the/tensorflow.whl
But if you just want to suppress the warning, this will do:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
I got the same issue and I was able to solve it by installing 1.3 version rather than using 1.4 of tensorflow. Use the following command to do so.
pip3 install tensorflow==1.3.0
I encountered the same problem and I fixed it by:
pip install --ignore-installed tensorflow
The problem occurred because I complied a local version of tensorflow (to enable some CPU features) with python 3.5 earlier. I installed python 3.6 recently and the new tensorlfow already supported those CPU features, so I just installed the official version.
Update:
After some update of tensorflow the approach above doesn't work any more.
Another workaround is using virtual environment such as anaconda to create a python3.5 environment:
conda create -n py35 python=3.5
source activate py35
pip install tensorflow
To work with ipython or jupyter notebook, be sure to install ipykernel inside the virtual environment:
pip install ipykernel
Just install 1.3 version of tensorflow. Problem solved.
pip install tensorflow==1.3.0
solution 1.
the way I solved this is by downgrading to the latest python3.5, go to python.org download the latest Python3.5, install it and then use normalpip3 install tensorflow this should be able to fix the issue if not try the second solution.
solution 2(also you need to downgrade from python3.6 to python3.5
I used Pycharm to solve the issue, I created a project inside the pycharm editor then I changed the Project Interpreter from python3.6 to python3.5, to do this as well go to File > Preferences search for Project Interpreter, and from the drop-down menu change from python3.6 to python3.5
hit Apply wait for the operation to finish
and then in the same window using the + icon
A window will appear that will let you search and install python libraries easily without using pip, in our case we want tensorflow, so just search tensorflow, select tensorflow on search result and click Install Package this will install the package
and voila you're ready to roll, now you got tensorflow installed on your python3.5, keep that in mind.
For now you can use python version less than 3.6.x because now Tensorflow 1.4.0 is not working properly with python 3.6.x. It will surly work.
This issue was resolved on ubuntu 17.10 by running
$ conda install tensorflow
i use tensorflow 1.4.0, meet the same problem. but you can use tensorflow 1.6.0, now.

Categories