Why does attribute 'bessel_i0e' keep disappearing in my conda envs? - python-3.x

I have been learning Tensorflow using Jupyter Notebook. I keep running into this error where I will restart a kernel on a notebook file, and when I type import tensorflow as tf I get following error
module 'tensorflow.python.ops.special_math_ops' has no attribute 'bessel_i0e'
With a bunch of other text. I have multiple conda envs, and when I switch to another env it works fine, even though they use the same cached version of tensorflow. I really have no idea what is happening.
Thank you!

I had to completely uninstall and reinstall tensorflow and keras to get rid of this error.
pip uninstall tensorflow-gpu tensorflow keras
pip install --upgrade tensorflow keras
did the trick for me.

Related

Tensorflow is installed and Tensorflow hub is installed still getting error

I have been googling and doing everything I have read about this issue and it seems it will not work and I cant figure it out.
Here is the issue:Tensorflow error
I have made sure that hub is installed and it is:
Tensorflow hub installed
This should be working and it keeps erroring out.
You can try updating tensor flow.
$ pip install --upgrade tensorflow # for Python 2.7
$ pip3 install --upgrade tensorflow # for Python 3.n
This may depend on what code editor you are using and what interoperator or package installer you are using. I think sometimes you might have to uninstall python. I am familiar with anaconda and I have had this problem but upgrading the module most of the time worked.
Its usually because there are multiple instalations or versions of python on the environment.

Importing Tensorflow on Python 3.6, 3.7, 3.8

I have a problem with importing TensorFlow. I have tried multiple versions of Numpy, Python, and TensorFlow and I still get the following error:
struct_pb2.TypeSpecProto.NDARRAY_SPEC
AttributeError: NDARRAY_SPEC
I have tried using conda and pip for installation and neither one works. I have no idea what might be the cause of this problem and it started happening about a week ago before that TensorFlow was working fine!
I believe you are using windows, and you have an incompatible version of tensorflow installed or you are missing a dependency. First make sure you have the following installed correct version of Visual C++ installed for your version of windows.
https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0
https://aka.ms/vs/16/release/vc_redist.x64.exe here is the direct link.
If it still doesn't work, enable longpaths,
https://superuser.com/questions/1119883/windows-10-enable-ntfs-long-paths-policy-option-missing
If you are having a clash with other packages, create a new conda environment first if you haven't already, and install tensorflow like this.
conda create -n tfenv
conda activate tfenv
conda install tensorflow
Then try to import tensorflow as tf again.

trouble importing Pytorch in Jupyter notebook

Iam new to deep learning and Iam trying to import Pytorch on Jupyter Notebook.
I installed Pytorch with the following lines of code in Anaconda Prompt.
conda create -n pytorch_p37 python=3.7
conda activate pytorch_p37
conda install pytorch torchvision -c pytorch
conda install jupyter
conda list
it all executed well.
but on importing pytorch it shows errors.
import torch
this error below:-
OSError: [WinError 126] The specified module could not be found
error showing image
The problem lied where I was installing a CUDA version.
I tried installing the CPU version and it worked fine (CUDA None).
conda install pytorch torchvision cpuonly -c pytorch
!pip install torch
It worked for me in a Anaconda's Jupyter notebook.
I lost one hour and found that launching the conda environment as stacked version does not lead to error:
in your example:
conda activate pytorch_p37
and from jupyter
import torch # error
from terminal:
conda activate --stack pytorch_p37
and from jupyter:
import torch # success
I could not figure out why :/
https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment

ImportError: No module named 'keras'

So basically, I am fairly new to programming and using python. I am trying to build an ANN model for which I have to use Tensor flow, Theano and Keras library. I have Anaconda 4.4.1 with Python 3.5.2 on Windows 10 x64 and I have installed these libraries by following method.
Create a new environment with Anaconda and Python 3.5:
conda create -n tensorflow python=3.5 anaconda
Activate the environment:
activate tensorflow
After this you can install Theano, TensorFlow and Keras:
conda install theano,
conda install mingw libpython,
pip install tensorflow,
pip install keras,
Update the packages:
conda update --all
All these packages are installed correctly and I have check them with conda list.
However, when I am trying to import any of these 3 libraries (i.e. Tensor flow, Theano and Keras), it is giving me the following error:
Traceback (most recent call last):
File "<ipython-input-3-c74e2bd4ca71>", line 1, in <module>
import keras
ImportError: No module named 'keras'
Hi I have an solution try this if you are using Anaconda-Navigator
go to Anaconda Environment and search keras package and then install.
after install just type import keras in shell its working.
Have you tried using keras documentation
Install Keras from PyPI (recommended):
Note: These installation steps assume that you are on a Linux or Mac environment. If you are on Windows, you will need to remove sudo to run the commands below.
sudo pip install keras
If you are using a virtualenv, you may want to avoid using sudo:
pip install keras
from: https://keras.io/
Now you need to have Tensorflow installed and then write, for example:
import tensorflow as tf
...
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Dense(12, input_dim=8, activation='relu'))
model.add(tf.keras.layers.Dense(8, activation='relu'))
model.add(tf.keras.layers.Dense(1, activation='sigmoid'))
...
Works for Tensorflow version: 2.4.1.
Or just type:
import tensorflow as tf
from tensorflow import keras
...
Try
import sys
print(sys.path)
and see if your anaconda site-packages folder is in the list.
It should be something like WHERE_YOU_INSTALLED_ANACONDA\anaconda3\envs\ENVIRONMENT_NAME\lib\python3.5\site-packages
If the path setting is correct, then try listing the folder content, and see if Keras, TensorFlow and Theano are in this folder.
I ran into a very similar issue after switching computers and downloading the latest Anaconda, which comes with python 3.6. It was no problem to install python 3.5 in its own environment, and install keras to this environment, but import keraskept failing.
My inelegant solution (assuming you've already got tensorflow/theano/cntk working fine in your global environment)?
Move the keras folder installed to Anaconda3/envs//Lib/site-packages/keras to Anaconda3/Lib/site-packages/keras. Now import keras gives a depreciation warning when run from a jupyter notebook launched via start menu, but it does work, and correctly returns the backend keras is running on.
I spent the whole day to install Keras, tried all the available methods online, almost dying. But I still cannot import keras.
(1). After using conda install or pip install, and delete the "1 > null > 2&1" ... I activated in conda prompt by activating tensorflow_cpu, it doesn't work anyway.
(2). Then checked the keras, and print os.path(), no virtual environment inside. I got so braindead, just copied all the keras data file from virtual environment env, and put into the "C:\Users\Administrator\Anaconda3\Lib\site-packages".
(3). Now, tensorflow and keras work well.
Click Update Index and then try searching for Keras again.
I have the same problem with:
conda 4.13.0
tensorflow 2.6.0
Note: We should not have to install Keras separately, as it ships with Tensorflow, starting with Tensorflow 2.0.
Symptoms:
Keras import (from tensorflow import keras) does not return an error, BUT any further reference to Keras does throw "ModuleNotFoundError", e.g. the following statements fail:
print(keras.__version__)
from keras import Sequential
I still don't have a direct solution for this, this is more of a workaround, but here it is:
Import ANY class from Keras JUST ONCE using full top-down import syntax AND instantiate it
Import Keras (now "for real")
E.g.:
from tensorflow.keras.layers import Dense
layer = Dense(10)
from tensorflow import keras
Now the following statements should work:
print(keras.__version__)
model = keras.models.Sequential()
This looks like some sort of lazy module loading gone wrong.
A direct and simple way to fix it is as below,
#uninstall keras and tensorflow
pip uninstall keras
pip uninstall tensorflow
#Now install keras and tensorflow for required version with dependencies.
pip install keras==2.2.4
pip install tensorflow==1.13.1
Always make sure that you install right version of tensorflow which supports that keras version as well, else you may end up in trouble again. By the way , the above fix worked for me.
I solved this problem by running one of the following in the terminal according to anaconda website.
To install this package (keras) with conda run one of the following:
conda install -c conda-forge keras conda install -c
conda-forge/label/broken keras conda install -c
conda-forge/label/cf201901 keras conda install -c
conda-forge/label/cf202003 keras
If you never use conda before you can check anaconda.
A direct and simple way to fix it is as below, #uninstall keras and tensorflow
py -3 -m pip uninstall keras
py -3 -m pip uninstall tensorflow
#Now install keras and tensorflow for required version with dependencies.
py -3 -m pip install keras
py -3 -m pip install tensorflow
the above fix worked for me.
If you are sure that you ran pip install keras at the command line, ensure that you use the small letter 'k' instead of the Capital Alphabet. I had a similar error message.
These are some simple steps to install 'keras' simply using the Anaconda Navigator:
Launch Anaconda Navigator. Go to the Environments tab.
Select ‘Not installed’, and type in ‘tensorflow’.
Then, tick ‘tensorflow’ and do the same for ‘keras’.
Click on ‘Apply’. The pop-up window will appear, go ahead and apply.
This may take several minutes.
Done.
This tutorial will guide you more graphically: https://www.freecodecamp.org/news/install-tensorflow-and-keras-using-anaconda-navigator-without-command-line/
Remember to launch spyder in the environment or activate it in line command (conda activate [my_env]. afater that, execute your script python.
Try to import keras library from its reference parent which means import tensorflow.keras

Error importing Tensorflow from Anaconda environment

I am quite a newbie with Anaconda and Tensorflow.
I am using Ubuntu 16.04 x64, I have installed Anaconda and works ok. After, I have installed Tensorflow following precise instructions from Tensorflow website:
$ conda create -n tensorflow
$ source activate tensorflow
(tensorflow)$ pip install --ignore-installed --upgrade tfBinaryURL
And I has also installed ok. I have activated the new environment, launched Spyder and tested the tensorflow test installation program:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
And I get the error importing Tensorflow:
ImportError: No module named tensorflow
Is there any environment variable to change? How can I solve this? I know it can ba a simple question, but I would appreciate a lot any advise for this...
PD: My intention is to later install Keras. Should it be as simple as activating the environment and install Keras using pip?

Resources