用docker部署superset碰到ModuleNotFoundError: No module named 'gevent'

问题:用dokcer部署superset时没碰到什么问题,但是一启动就报如标题的错误。

报错:
superset_1 | File "/usr/local/lib/python3.6/site-packages/celery/__init__.py", line 110, in _patch_gevent
superset_1 | import gevent
superset_1 | ModuleNotFoundError: No module named 'gevent'
superset_1 | npm ERR! path /home/superset/superset/assets/node_modules
superset_1 | npm ERR! code EACCES
superset_1 | npm ERR! errno -13
superset_1 | npm ERR! syscall mkdir
superset_1 | npm ERR! Error: EACCES: permission denied, mkdir '/home/superset/superset/assets/node_modules'
superset_1 | npm ERR! { [Error: EACCES: permission denied, mkdir '/home/superset/superset/assets/node_modules']
superset_1 | npm ERR! cause:
superset_1 | npm ERR! { Error: EACCES: permission denied, mkdir '/home/superset/superset/assets/node_modules'
superset_1 | npm ERR! type: 'OperationalError',
superset_1 | npm ERR! '$error': '$error',
superset_1 | npm ERR! cause:
superset_1 | npm ERR! { errno: -13,
superset_1 | npm ERR! code: 'EACCES',
superset_1 | npm ERR! syscall: 'mkdir',
superset_1 | npm ERR! path: '/home/superset/superset/assets/node_modules' },
superset_1 | npm ERR! isOperational: true,
superset_1 | npm ERR! errno: -13,
superset_1 | npm ERR! code: 'EACCES',
superset_1 | npm ERR! syscall: 'mkdir',
superset_1 | npm ERR! path: '/home/superset/superset/assets/node_modules' },
superset_1 | npm ERR! isOperational: true,
superset_1 | npm ERR! stack:
superset_1 | npm ERR! 'Error: EACCES: permission denied, mkdir '/home/superset/superset/assets/node_modules'',
superset_1 | npm ERR! type: 'OperationalError',
superset_1 | npm ERR! '$error': '$error',
superset_1 | npm ERR! errno: -13,
superset_1 | npm ERR! code: 'EACCES',
superset_1 | npm ERR! syscall: 'mkdir',
superset_1 | npm ERR! path: '/home/superset/superset/assets/node_modules' }
superset_1 | npm ERR!
superset_1 | npm ERR! The operation was rejected by your operating system.
superset_1 | npm ERR! It is likely you do not have the permissions to access this file as the current user
superset_1 | npm ERR!
superset_1 | npm ERR! If you believe this might be a permissions issue, please double-check the
superset_1 | npm ERR! permissions of the file and its containing directories, or try running
superset_1 | npm ERR! the command again as root/Administrator (though this is not recommended).
superset_1 |
superset_1 | npm ERR! A complete log of this run can be found in:
superset_1 | npm ERR! /home/superset/.npm/_logs/2019-05-07T07_07_04_026Z-debug.log

补充信息:我这个centos7系统之前装过好几个python,平时使用python时,查找包的地址和报错里是不一样,如下
[root@rac1 docker]# ls -lh /usr/bin/ |grep python
lrwxrwxrwx 1 root root 27 May 6 07:59 pip3 -> /usr/local/python3/bin/pip3
lrwxrwxrwx 1 root root 7 May 5 12:12 python -> python2
lrwxrwxrwx 1 root root 9 May 5 12:12 python2 -> python2.7
-rwxr-xr-x 1 root root 7.1K Apr 9 22:31 python2.7
lrwxrwxrwx 1 root root 32 May 6 07:59 python3 -> /usr/local/python3/bin/python3.6

求救:我想知道怎么在docker里补上包啊,启动不了的情况下!docker不是一切都是自带吗?库竟然还要我自己下载?!是不是镜像问题啊。

阅读 6.9k
1 个回答

问题原因:
某个py文件代码中导入了'gevent'包,但是docker容器里没有安装该包,运行到这一步就会报错。

解决方法:

  • 找到该py文件,将导入'gevent'相关的语句先注释掉。
  • 进入容器命令行
    docker exec -it container_id(容器id) bash
  • 命令行安装'gevent'包
    pip install gevent
  • 将修改的docker提交生成新的image
    docker commit -m "修改备注" new_iamges(镜像名):v1(版本号)
  • 查看新的docker镜像
    docker images
  • 删除原有容器
    docker rm container_id
  • 重新构建容器
    docker run -d --name newcontainer -p 8080:8080 new_iamges:v1 cmd(执行命令)
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题