When I am trying to run this
import keras
I am getting following error:
Traceback (most recent call last):
File "<ipython-input-1-c74e2bd4ca71>", line 1, in <module>
import keras
File "/Users/rezwan/anaconda/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/Users/rezwan/anaconda/lib/python3.6/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/Users/rezwan/anaconda/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 3, in <module>
from .. import backend as K
File "/Users/rezwan/anaconda/lib/python3.6/site-packages/keras/backend/__init__.py", line 83, in <module>
from .tensorflow_backend import *
File "/Users/rezwan/anaconda/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2, in <module>
from tensorflow.python.training import moving_averages
ModuleNotFoundError: No module named 'tensorflow.python.training'
Already I have installed Theano, Tensorflow and Keras through the following commands:
Theano:
Rezwans-iMac:~ rezwan$ pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
Tensorflow:
Rezwans-iMac:~ rezwan$ conda create -n tensorflow python=3.6
Rezwans-iMac:~ rezwan$ source activate tensorflow
(tensorflow) Rezwans-iMac:~ rezwan$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.3.0rc2-py3-none-any.whl
(tensorflow) Rezwans-iMac:~ rezwan$ pip3 install --upgrade $TF_BINARY_URL
Keras:
Rezwans-iMac:~ rezwan$ pip install --upgrade keras
Above commands work properly.
But I am getting above error. How can I solve this error?
To make sure all libraries are installed, you can use a text file with something like this:
jupyter==1.0.0
Keras==2.1.3
numpy==1.15.1
pandas==0.22.0
scikit-learn==0.19.1
scipy==1.0.0
tensorboard==1.10.0
tensorflow==1.10.0
Then use pip to install:
pip install -r requirements.txt
or
pip3 install -r requirements.txt
All libraries will be installed for use in the same python version, in case you have multiple installations.
Your tensorflow installation commands:
Rezwans-iMac:~ rezwan$ conda create -n tensorflow python=3.6
Rezwans-iMac:~ rezwan$ source activate tensorflow
(tensorflow) Rezwans-iMac:~ rezwan$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.3.0rc2-py3-none-any.whl
(tensorflow) Rezwans-iMac:~ rezwan$ pip3 install --upgrade $TF_BINARY_URL
created and activated a virtual environment called tensorflow. Notice the (tensorflow) before Rezwans-iMac, indicating that you are inside the newly created virtual environment. Since tensorflow is only installed in this virtual environment, you need to switch into it with
source activate tensorflow
everytime you want to use tensorflow. You will also need to install other packages that you want to use inside this environment.
Also configure your IDE to use the interpreter in .../anaconda/env/tensorflow/bin/python
Upgrading tensorflow to "1.15.2" Solved the issue for me.
Seems like tensorflow doesn't have backword compatibility with
Related
I have a tensorflow 2.2 conda environment setup with python 3.8.2 on Ubuntu.
I ran pip install tensorflow-io==0.14.0.
When I try to
import tensorflow-io as tfio
I get the erorr:
File "/home/somedir/miniconda3/envs/env_name/lib/python3.8/site-packages/tensorflow_io/core/python/ops/__init__.py", line 65, in _load_library
raise NotImplementedError(
NotImplementedError: unable to open file: libtensorflow_io.so, from paths: ['/home/somedir/miniconda3/envs/env_name/lib/python3.8/site-packages/tensorflow_io/core/python/ops/libtensorflow_io.so']
caused by: ['/home/somedir/miniconda3/envs/env_name/lib/python3.8/site-packages/tensorflow_io/core/python/ops/libtensorflow_io.so undefined symbol:
_ZN10tensorflow0pKernel11TraceStringEPNS_150pKernelContextEb']
What's the issue and how can I fix it?
As #Smedegaard mentioned, tensorflow_io is not on conda forge. The answer of vlasenkoalexey on Github issues to tackle this:
Obvious workaround is to uninstall tensorflow and tensorflow-io and install them from pip:
pip uninstall tensorflow
pip uninstall tensorflow-io
pip install tensorflow-gpu
pip install --no-deps tensorflow-io
I got the same error in a Jupyter lab, running in a conda environment.
Looks like tensorflow_io is not on conda forge yet: https://github.com/tensorflow/io/issues/676
If possible you can change to a regular Python environment.
Solution:
!pip install tensorflow_io==0.17.1
!pip install tensorflow==2.4.0
at 19 oct 2022, it is work with that versions
#!pip install tensorflow==2.8.0
#or
!pip install tensorflow-gpu==2.8.0
import tensorflow as tf
!pip install tensorflow-io==0.25.0 # что сломалось с ==0.26.0
Have you tried pip install tensorflow-io==0.13.0 ?
according to This TF has 2 version of TF io that can be compatibly installed with.
I have installed anaconda , and use conda install -c anaconda tensorflow-gpu to install tensorflow .
I activate tensorflow by using source activate tensorflow sucessfully, but I find that I can't use other anaconda packages , such as pandas .
How to use tensorflow and anaconda packages sucessfully?
Here is my operations and the versions of anaconda and tensorflow.
anaconda version:
# Name Version Build Channel
anaconda 5.3.0 py37_0
tensorflow version:
(base) anonym2#amax:/data/anonym2/code$ source activate tensorflow
(tensorflow) anonym2#amax:/data/anonym2/code$ python -c 'import tensorflow as tf; print(tf.__version__)'
1.5.0
import pandas in tensorflow environment:
(tensorflow) anonym2#amax:/data/anonym2/code$ import pandas
import: unable to open X server `localhost:10.0' # error/import.c/ImportImageCommand/364.
(tensorflow) anonym2#amax:/data/anonym2/code$ python test.py
Traceback (most recent call last):
File "test.py", line 9, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Please read conda usage first.
conda install -n your_env_name pandas may solve import pandas error, and replace your_env_name into your own environment name.
You have to install packages as many as you need. To avoid this, you could create an environment with a specific version of anaconda python before installing tensorflow by conda create -n your_env_name python=3.7 anaconda. The python version can be changed as you want.
I want to run keras on anaconda for convolution neural network using mnist handwriting recognition. A day before everything worked fine but as I try to run the same program, i get the following error in the first line:
from keras.datasets import mnist (first line of code)
ModuleNotFoundError: No module named 'keras.datasets'; 'keras' is not
a package
I also created virtual environment to use python 3.5 as my python version is 3.6. I have installed both keras and tensorflow. How do i fix the above error? Perhaps it is related to path and not error with keras. My anaconda is installed in E: whearas working environment is C:\Users\Prashant Mahato.
Do you get an error message if you just import keras? I was getting a similar error in the command line and then implemented in Spyder (using Anaconda) and it worked fine.
Here is how I install Keras and other related dependencies
conda create -n <Environment_Name> python=3.6
activate <Environment_Name>
conda update --all
conda install mingw libpython
conda install scipy
conda install numpy
conda install mkl
conda install -c conda-forge tensorflow
conda install theano
pip install pyyaml
pip install h5py
pip install keras
conda install -c conda-forge tmux
conda install pandas
condas install pillow
conda install scikit-learn
conda install -c menpo opencv3
To check if everything is work as it should just import all the packages in python within the environment created.
I'm running Windows 10 and Anaconda 4.2
If running Ubuntu, replace
activate <Environment_Name>
with
source activate <Environment_Name>
HTH.
I have started to install SciPy using:
pip install --user numpy scipy matplotlib ipython jupyter pandas simply nose
It installed but when I want to go into ipython I get this error:
ImportError: No module named shutil_get_terminal_size
I tried uninstalling python then reinstalling it as well as uninstalling and reinstalling SciPy. I've also upgraded pip setup tools as well as python. It says that shutil_get_terminal_size has been installed:
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 7, in <module>
from IPython import start_ipython
File "/usr/local/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
from .core.application import Application
File "/usr/local/lib/python2.7/site-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/usr/local/lib/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in <module>
from IPython.core import ultratb
File "/usr/local/lib/python2.7/site-packages/IPython/core/ultratb.py", line 128, in <module>
from IPython.utils.terminal import get_terminal_size
File "/usr/local/lib/python2.7/site-packages/IPython/utils/terminal.py", line 22, in <module>
from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size
ImportError: No module named shutil_get_terminal_size
I just need to be able to get SciPy and ipython working.
You need to update your version of pip and then install ipython again.
sudo pip install --upgrade setuptools pip
pip uninstall --user ipython
pip install --user ipython
I have also faced the same issue.This is the issue of conda environment. That's why it is giving the error in ipython notebook.Try out this one.
conda update conda
conda update ipython
After trying this,if you are facing same issue.then try to install ipython inside your conda environment.Activate your conda environment first.then do as follows.
pip install --upgrade setuptools pip
ex: (dato-env) pydev#Optimus:~$ pip install --upgrade setuptools pip
then install ipython inside conda environment
pip install -U ipython
ex : (dato-env) pydev#Optimus:~$ pip install -U ipython
then open Jupyter notebook from the terminal and it will open jupyter on your browser.
(dato-env) pydev#Optimus:~$ jupyter notebook
Hope it helps.
I try to import scikit-learn, but there is an error. i installed sklearn, scipy on anaconda. i am using W10 and python 3.5.
>>> import sklearn
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import sklearn
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\__init__.py", line 57, in <module>
from .base import clone
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\base.py", line 9, in <module>
from scipy import sparse
ImportError: No module named 'scipy'
In linux there is pip install <module> to install a module, and if you are using anaconda then conda install <module>, I believe there would be something similar in windows.
If you are sure that you have installed scipy module, then probably the python path is not looking for those directories.
You can try a environment variable PYTHONPATH that has a list of directories to append before launching python prompt. OR you can test it for a session by adding it to sys.path
Use pip to install the packages
pip install numpy
pip install scipy
pip install -U scikit-learn
Ensure you have appropriate privileges for installing globally or in virtual environment.
Using pip, or interpreter setting in pycharm:
pip install NumPy+mkl
numpy-mkl 1.10.2
Install module NumPy+mkl
pip install SciPy
Install module SciPy
Now you can install sklearn.
pip install scikit-learn
Install module scikit-learn
Hope that it is useful.