问题:
我正确安装了keras
和tensorflow
。尽管它们都已安装,但是在import keras
时遇到以下错误:
File "/root/PycharmProjects/DeepLearning/paper/test.py", line 1, in <module>
import keras.activations
File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/backend/__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "/home/saeed/.conda/envs/py35/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py", line 6, in <module>
from tensorflow.python.framework import ops as tf_ops
ImportError: No module named 'tensorflow.python'; 'tensorflow' is not a package
我的努力:
我尝试了以下解决方案1,2,3,但未找到结果。还要卸载keras
和tensorflow
,然后重新安装,但没用。
问题出在哪里?
系统:Ubuntu 18.04.1 LTS
Python :3.5
Keras :2.2.2
tensorflow :1.10.0
答案 0 :(得分:1)
Pip3 install
命令而不是pip install
应该可以解决问题。
答案 1 :(得分:0)
由于您使用的是Python3 +,因此我将使用pip3 install tensorflow==2.0.0
from tensorflow.keras import <whatever-module-you-need>
Tensorflow是Keras API。您可以从任何一个导入!