Reputation: 19
I'm try learning TensorFlow but i have a problem. I'm importing TensorFlow like in official website but i take a error.
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
Traceback (most recent call last):
File "C:\Users\Koray\Desktop\Python\main.py", line 4, in
from tensorflow import keras
ImportError: cannot import name 'keras' from 'tensorflow'
(C:\Users\Koray\Desktop\Python\tensorflow.py)
Upvotes: 0
Views: 8273
Reputation:
For community benefit, adding @John Gordon answer here in the answer section.
Don't name your script
tensorflow.py
. Your import finds that script instead of the real one.
Instead you can name any other for example learning.py
. Now all your imports work as expected.
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
Upvotes: 0