I'm using anaconda ver 3, and I have installed python as well separately from anaconda. I installed python ver 2.7 and ver 3.6 from python website.
Now, I have installed keras from anaconda command prompt by using conda install keras. However, when I open jupyter notebook and write :
import keras
it says :
no module named keras
I also tried importing tensorflow but it gave me the same error
As far as i know, keras is a version of tensorflow. You should try installing tensorflow instead and then run
import tensorflow as tf
tf.__version__
if you get '2.1.0' or any 2., you should be all set!
EDIT1: Keras is part of tensorflow not a version (as pointed out in the comments).
EDIT2: The link below gives good details on environments activation/creation.
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
Okay so what I did is first updated anaconda by using :
conda update conda
and then I installed python :
conda install python=3.7
and finally I installed keras again :
conda install keras
And now I can import both packages of keras and tenserflow
Related
Hi
in jupyter notebook, when i tried to import tensorflow like below, i got an error of ModuleNotFoundError: No module named 'tensorflow'. Then, I opened anaconda prompt and trying to install tensorflow in anaconda and it failed many times and here is the error message. Could you please help me what is the problem? Thanks
import tensorflow as tf
ok, so i tried to downgrade python from 3.8 to 3.6 and i still got an error at the end, could anyone help pls? Thanks
EnvironmentNotWritableError: The current user does not have write permissions to the target environment.
environment location: C:\ProgramData\Anaconda3
According to TensorFlow docs, tf is compatible with python 3.5, 3.6, 3.7 or 3.8
and also python 3 64bit release is a must, so it's maybe worth to check if you don't try to install tf accidentally on 32bit version of python.
https://www.tensorflow.org/install/pip#windows
import sys
print(sys.version)
I installed tf according to Anaconda docs:
create fresh env,
activate it,
and install tf:
conda create -n myproject tensorflow
conda activate myproject
conda install tensorflow
I can see that conda automatically selected python version 3.7.9
verify:
import tensorflow as tf
tf.version.VERSION
your python version is not compatible with this version of tensorflow. you are using python 3.8 downgrade python to either 3.5, 3.6 or 3.7. downgrading python should solve your issue.
I am reading "Hands-On Machine Learning with Scikit-Learn, Keras and Tensorflow" and installed Tensorflow 2 as follows:
$ python3 -m pip install --upgrade tensorflow
In the jupyter notebook I tried to import Tensorflow as follows:
import tensorflow as tf
But then I get the following error message:
The kernel appears to have died. It will restart automatically
I know there is a bunch of StackOverflow threads about this topic. I have read them all. Some of them are old, some are new. Most of them suggest to downgrade the Tensorflow version to 1.5. But when I do that I can not use some of the methods of the Keras API (e.g. load_data() could not be found).
Is there anyone who have found a solution for that?
The second version of the textbook is all about TensorFlow version 2 so you have to use TensorFlow version 2 to use code. if there is a problem get the first version of the textbook which uses TensorFlow 1.
But I suggest learning TensorFlow 2 as it is the latest version.
if you are using anaconda Try installing TensorFlow 2 in a new environment.
To create a new environment open anaconda prompt.
conda create -n envname python=3.6
and then activate the environment
activate envname
Now try installing TensorFlow 2 and other necessary modules
and check.
If it does not work the best solution is to use google colab(colab.research.google.com/).where you can do everything online, you can even have free GPU.
When I issue an Anaconda prompt conda search pytorch
then I get pytorch installed even issuing conda list command gives me:
pytorch 1.5.1 py3.7_cuda102_cudnn7_0 pytorch
But when I start python on command prompt and then issue import pytorch i get ModuleNotFoundError: No module named 'pytorch'.
Even I tried to do the same after issuing
conda create -n pytorch_env -c pytorch pytorch torchvision
conda activate pytorch_env
conda install -c pytorch pytorch torchvision
as written in Installing PyTorch via Conda but of no use. BTW does it require a restart of the machine after installing Anaconda? Also, let me know how I can use PyTorch in Jupyter notebooks.
Verify the installation with import torch not pytorch. Example code below, source.
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
If above throws same issue in Jupyter Notebooks and if you already have GPU enabled, try restarting the Jupyter notebook server as sometimes it requires restarting, user reported.
when I tried to import this package from Jupyter notebook, I got following error message: ModuleNotFoundError: No module named 'torch'. Then, I tried installing Jupyter notebook application from Anaconda navigator for my environment(torch).
Restarted my Jupyter notebook and ran import torch and this time it worked
Otherwise, you need CPU only version of PyTorch.
conda install pytorch torchvision cpuonly -c pytorch
I installed anaconda and I installed Keras and tenserflow by defining a new environment.
conda create -n keras python=3.7.6
conda activate keras
conda install keras
I wanted to use matplotlib , but I got error that No module named 'matplotlib.
So I decided to create and activate it the same as I did for keras above.
But these packages don't work at the same times! when I load package keras and Tensorflow in anaconda . it's fine and they work. but when I load matplotlib , keras and Tensorflow are removed from loaded packages. and when I load keras and tensorflow , 'matplotlib is removed. this is so odd to me! any idea?
For example I installed matplotlib and you can see in this picture keras and tensorflow are in the non-installed packages in anaconda. Now if I install them matplotlib will be in the non-installed list.
I created an environment on conda and installed the tensorflow on it, with following the instruction from here. I check the tensorflow version on my environment with pip list | grep tensorflow
and it returns tensorflow (1.3.0).
but when I want to check tensorflow with python with import tensorflow as tf I got the error:Failed to load the native TensorFlow runtime.
Any suggestion how to solve this issue? Thanks
fixed it by this command:
conda install -c https://conda.anaconda.org/jjhelmus tensorflow
from this post