ModuleNotFoundError: No module named 'tensorflow.python.trackable' - python

The statement is:
from tensorflow.python.trackable import base as trackable
But the module not found error is coming up.
##### File "C:\Users\mahit\anaconda3\lib\site-packages\keras\dtensor\lazy_variable.py", line 26, in <module>
from tensorflow.python.trackable import base as trackable
ModuleNotFoundError: No module named 'tensorflow.python.trackable'
The piece of code is inside keras library. I dont understand why this module not found error is coming up. Becase this is a code that came with the package. Also not sure what trackable does. Please help me resolve this.

The solution for me was to install keras in version 2.9.0
pip install keras==2.9.0

I got rid of this error: uninstall tensorflow and install tf-nightly. Nevertheless, I got another error: Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice
In python code, with Linux OS, that error could be solved by using command: os.environ['XLA_FLAGS'] = '--xla_gpu_cuda_data_dir=/usr/lib/cuda/'

I had the same problem for the past one month and I was not able to resolve it. Then finally I just uninstalled tensorflow and installed tf-nightly with immediately resolved the issue.
The issue occurs as tensorflow recently moved the keras out of the default package and now is only available through the tf-nightly install.
Hope this resolves the issue

I have the same issue and have been check the current dir of tensorflow, the trackable folder does not exist.
So here is an easy way.
Git clone from the url: https://github.com/tensorflow/tensorflow
Find the tensorflow -> python -> trackable
Copy the trackable folder to your tensorflow install dir (For example: C:\Users\xxxx\anaconda3\Lib\site-packages\tensorflow\python).

Uninstall tensorflow using pip uninstall tensorflow and install pip install tf-nightly
This fix worked for me perfectly well.

I just got this error in CI builds with a requirements.txt that had
keras
tensorflow==2.9.1
and I assume the error was caused by pip install -r requirements.txt taking the recently released Keras 2.10 version, which probably assumes it's running next to TensorFlow 2.10, and that the minor mismatch led to this import error.

Related

module 'tensorflow.core.framework.types_pb2' has no attribute 'SerializedDType'

Does anyone have a solution for this kind of error when I try to import tensorflow:
module 'tensorflow.core.framework.types_pb2' has no attribute 'SerializedDType'
(https://i.stack.imgur.com/VAc6i.png)](https://i.stack.imgur.com/Bg5vW.png)
I faced the same problem when I tried to reinstall tf from 2.11.0 to 2.7.0. Trying to fix the issue I uninstalled separately tf and keras and reinstalled them but it did not help. Finally, I uninstalled both again and additionally manually deleted all the folders with tf files in venv\Lib\site-packages directory. After that I installed tf 2.11.0 and now everything works fine. I use pip for all the installation procedures in manually created venv, no Anaconda.

Error: cannot import name 'SpearmanRConstantInputWarning' from 'scipy.stats'

I'm getting an error when importing the skbio package on Google Colab. The error message is related to SpearmanRConstantInputWarning of the scipy.stats package. What should I do to solve this problem?
I've tried to uninstall and install skbio and scipy, but it has not worked.
Seems to be some issue with the version. If you run
pip install scikit-bio==0.5.6
it shouldn't show that problem, at least it worked when I tried for 0.5.6 and 0.5.5 in Colab.
I had a similar problem, but could not downgrade to scikit-bio==0.5.6 as it conflicted with my Python version (3.10). An alternative workaround is downgrading scipy:
conda install -c conda-forge scipy=1.8
Presumably which package to downgrade will depend on your circumstances.
(Would have added as a comment to 3991santiago's answer but I do not have the reputation)

No module named 'bindsnet.network'

I am going to use Bindsnet for Spiking Neural Network and I have imported it using
! pip install bindsnet in jupyter notebook.
and My Python's version is 3.6.
when I run:
from bindsnet.network import Network
It returns below error message:
ModuleNotFoundError: No module named 'bindsnet.network'
Can you please let me know how to solve this?
It turned out that using pip install was not successful so I changed the code for installation to :
!pip install bindsnet --ignore-installed
and now I can run from bindsnet.network import Network with no error.

Tensorflow error " ImportError: DLL loaad failed with error code-1073741795"

Issue in importing TENSORFLOW(error code-1073741795 in jupyter notebook, Pycharm, Anaconda command line and in spyder. Howevery I am able to install successfully. But when I'm trying import then I am getting this error
"ImportError: DLL load failed with error code-1073741795".
I have install all the versions of VS redistributable.
I am using win 7 with 64 bit os. I tried to install on tensorflow on all the versions of python 3.6, 3.7
& 3.8. with different versions of tensorflow. Did anyone encountered with error code-1073741795???
ImportError: DLL load failed with error code-1073741795
Failed to load the native tensorflow runtime.
See https://www.tensorflow.org/install/errors
what does error code-1073741795 means?
How do we fix it.
I got an error like this when installing tensorflow. It was because tensorflow was not installed properly.
First, delete your current installed tensorflow completely.
Install Anaconda.
Make a new conda environment (this will help).
After creating a conda environment, activate it.
After activating, write: 'conda install tensorflow==1.15.0'
I am suggesting tensorflow 1.15.0 because I have found it more stable and better than any other version.
To test it is working properly, write:
python
This will activate python, then write:
import tensorflow as tf
print(tf.__version__)
You may get some warnings when importing tensorflow, but ignore the warnings, you will not get any errors. (if you get any error, comment)

AttributeError: keras.backend ,no attribute 'eager'

I'm using python 3.8.2 , keras 2.3.1 and tensorflow 2.2.0rc4 .
just with the following code :
import keras
from keras.models import sequential
I have this error :
AttributeError: partially initialized module 'keras.backend' has no attribute 'eager' (most likely due to a circular import)
if I use :
import tensorflow
or
from tensorflow.keras import ....
new error :
AttributeError: partially initialized module 'tensorflow.python.framework.ops' has no attribute 'register_tensor_conversion_function' (most likely due to a circular import)
full traceback:
enter image description here
enter image description here
My suggestion is to reinstall the package. Sometimes this happens due to the installation problem.
Use the following code to do so
Uninstall tensorflow
pip uninstall tensorflow
Requires the latest pip
pip install --upgrade pip
To install keras as separate package
pip install Keras
Current stable release for CPU and GPU
pip install tensorflow
Try this and hope this helps you.
It's an install problem, most likely; K.eager was introduced in Keras 2.3.0 (and is included in Keras 2.3.1), so your Python interpreter is somehow reading code of 2.2.5 or earlier.
A possible culprit is an Anaconda mishap. First run conda uninstall keras. Then, in the anaconda3 directory, search "keras" and delete all results. Lastly, run conda install -c conda-forge keras, which should download version 2.3.1. You might need to run similar steps with TensorFlow (in fact, it's better you do, and first reinstall TensorFlow then Keras).
P.S., your code is probably from keras import Sequential, as sequential should error differently.

Categories