Fne 2018-09-13 09:46 采纳率: 50%
浏览 5762
已采纳

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 matlab,文献复现
  • ¥20 寻找Flink CDC指导,有偿咨询
  • ¥15 cruise如何仿真不同温度下车辆的经济性?
  • ¥20 扑克牌游戏的完整代码
  • ¥88 求帮安装Python架构的vnpy
  • ¥20 逻辑回归法分析品牌知名度和购买意向
  • ¥15 华为云主机-异常连接
  • ¥50 vue 成绩列表 输入成绩,并统计各分数段人数
  • ¥20 请教怎么绕过这个卡密系统 大家交流一下
  • ¥15 设计数字电路得到要求结果