tensorflow import bug: No module named 'tensorflow.python.eager.polymorphic_function' - tensorflow

I am trying to import the tensorflow module in my jupyter notebook, however this error appears. I have imported ternsorflow before, therefore I am not cure why it is showing the error: ModuleNotFoundError: No module named 'tensorflow.python.eager.polymorphic_function' . Could someone help me fix this?
I tried checking if tensorflow is installed, and indeed it is.

Related

ModuleNotFoundError: No module named 'seaborn' in spdyer

I recently installed spyder on my macbook (M1). I am getting module not found error when I tried to load seaborn.
Pl note
I am able to load the seaborn in jupyter notebook
Whey I change the python interpreter to the the one jupyter notebook is using (i.e. miniforge), I get following error
/Users/akbarboghani/miniforge3/bin/python: Error while finding module specification for 'spyder_kernels.console' (ModuleNotFoundError: No module named 'spyder_kernels')
Is there any setting I have missed? How do I resolve this
I tried changing preferences and restarted the spyder application. Checked for solution, did not find any.

Pycharm highlights code import tensorflow.compat.v1

I've got code that does import tensorflow.compat.v1. Import is going with no errors but PyCharm highlighted this code and says No module named compat. My tensorflow version is 2.4.1
Why does PyCharm say that there's no module compat but the program executes correctly?
Why doesn't the program fails on this line while executing?
I guess rewriting it as import tensorflow._api.v2.compat.v1 as tf would work
Update TF-GPU to 2.6+, then problem solved.

Error on Scope Variable While Using Tensorflow Hub

I am using Colab to run a text analysis code. I am want to get universal-sentence-encoder-large from tensorflow_hub.
But anytime running the block containing the code below:
module = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3")
I get this error:
RuntimeError: variable_scope module_8/ was unused but the
corresponding name_scope was already taken.
I appreciate if you have any idea how this error can be fixed?
TF Hub USE-3 Module doesn't work with Tensorflow Version 2.0.
Hence, if you change the version from 2.0 to 1.15, it works without any error.
Please find the working code mentioned below:
!pip install tensorflow==1.15
!pip install "tensorflow_hub>=0.6.0"
!pip3 install tensorflow_text==1.15
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
import tensorflow_text
module = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3")
Please find the Github Gist of Google Colab as well.
With tensorflow 2 in google colab you should use hub.load(url) instead of hub.Module(url)

AttributeError: module 'pandas' has no attribute '_libs'

whenever i try to import pandas in jupyter notebook, i get the error as following:
AttributeError: module 'pandas' has no attribute '_libs'
How to fix it? i am just new to programming
Close the terminal. Restart jupyter notebook / lab fixes the problem.
I got this error as well, and just fixed it by just updating conda & pandas while using Anaconda
I used to get the same:
AttributeError: module 'pandas' has no attribute '_libs' error
Whenever I used to open the old file in Jupyter notebook, but you can open a new file and then try importing the Pandas it will work.

Cannot import Keras on Pycharm

I tried to code on Pycharm, but when I use from keras import backend as K it throws an import error like "cannot import name backend". But I can do it on terminal.
How can I fix this?
error
on terminal
Are you sure your PyCharm sees the same Python environment as what you are using in Terminal?
See if this possibly works for you:
use tensorflow on pyCharm
I got the same problem:
Check here:Pycharm cannot find installed packages: keras
After adding new package to project interpreter, you need to quit Pycharm and restart it again.
Use
from tensorflow.python.keras import backend as K
instead.