Docker Permission denied 和 pip ImportError: cannot import name 'main'

背景: 在 CentOS 上用 Docker 部署遇到一些坑。
系统为 CentOS 7 , 升级了 pip(19) 后, 直接敲 pip install docker 安装 Docker。结果:

ImportError: cannot import name 'main'

上网搜索了大部分解决办法都不行,可能环境和版本都有差异吧。

解决办法

我的 macOSpip 是没问题的啊,于是:more /usr/local/lib/python3.7/site-packages/pip/__main__.py

from __future__ import absolute_import

import os
import sys

# If we are running from a wheel, add the wheel to sys.path
# This allows the usage python pip-*.whl/pip install pip-*.whl
if __package__ == '':
    # __file__ is pip-*.whl/pip/__main__.py
    # first dirname call strips of '/__main__.py', second strips off '/pip'
    # Resulting path is the name of the wheel itself
    # Add that to sys.path so we can import pip
    path = os.path.dirname(os.path.dirname(__file__))
    sys.path.insert(0, path)

from pip._internal import main as _main  # isort:skip # noqa

if __name__ == '__main__':
    sys.exit(_main())

答案很明显了。
然后开心的装了 docker(Docker version 1.13.1)docker-compose(docker-compose version 1.24.1) 后,准备 docker-compose up -d

然后又出问题:

Creating wechat_auto_reply_web_1 ... done
Attaching to wechat_auto_reply_web_1
web_1  | python: can't open file './auto_reply.py': [Errno 13] Permission denied
wechat_auto_reply_web_1 exited with code 2

在加了权限和尝试各种方法后,解决办法

以上,问题都解决了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容