ubuntu下调用keras报错:No module named 'error'

cuda9.0和TensorFlow1.8.0已安装
import tensorflow也没有问题,就是再import keras出错,求大神解答!
报错如下:
Using TensorFlow backend.
Traceback (most recent call last):
File "/home/zhangzhiyang/PycharmProjects/tensorflow1/test_keras.py", line 2, in
import keras
File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/__init__.py", line 3, in
from . import utils
File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/utils/__init__.py", line 26, in
from .multi_gpu_utils import multi_gpu_model
File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/utils/multi_gpu_utils.py", line 7, in
from ..layers.merge import concatenate
File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/layers/__init__.py", line 4, in
from ..engine.base_layer import Layer
File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/__init__.py", line 7, in
from .network import get_source_inputs
File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/network.py", line 9, in
import yaml
File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/yaml/__init__.py", line 2, in
from error import *
ModuleNotFoundError: No module named 'error'

我的版本:tensorflow1.8.0,cuda9.0,cuDNN7,anaconda3,python3.6.5
我的tensorflow和keras安装路径均为anaconda3/envs/tensorflow/lib/python3.6/site-packages

我的.bashrc文件如下:

export PATH="/home/zhangzhiyang/anaconda3/bin:$PATH"
export LD_LIBRARY_PATH="/home/zhangzhiyang/newdisk/cuda-9.0/lib64:$LD_LIBRARY_PATH"
export PATH="/home/zhangzhiyang/newdisk/cuda-9.0/bin:$PATH"
export CUDA_HOME=$CUDA_HOME:"/home/zhangzhiyang/newdisk/cuda-9.0"

个人推测可能是python版本的问题,但不知如何解决,我第一次pip Keras未指定安装路径,结果keras安装在了python2.7下,这次我指定了路径为python3.6/site_packages,但是报了如上错误,是否keras不支持python3?

求大神解答!

1个回答

keras是支持python3的,tensorflows自带keras的
可以试下from tensorflow import keras

TearjerkerR
Everyday Struggle 太谢谢您了!!
一年多之前 回复
weixin_39416561
lyhsdy 回复qq_33768843: from tensorflow.keras import Sequential ;from 文件夹.子文件夹 import 函数/类名,你找到对应的目录就知道怎么去调用了,直接import kera是直接使用kera这个包,造成这种出错是因为tensorflow的开发者在kera基础上做了优化
接近 2 年之前 回复
qq_33768843
Fne 还有就是为什么直接import kera会报错
接近 2 年之前 回复
qq_33768843
Fne 非常感谢,from tensorflow import keras没有报错,但这种情况怎么import Sequential?
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问