Fne
2018-09-13 09:46
采纳率: 50%
浏览 5.6k

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条回答 默认 最新

  • lyhsdy 2018-09-14 01:49
    已采纳

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

    点赞 3 评论

相关推荐 更多相似问题