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

背景: 在 CentOS 上用 Docker 部署遇到一些坑。
系統(tǒng)為 CentOS 7 , 升級(jí)了 pip(19) 后, 直接敲 pip install docker 安裝 Docker。結(jié)果:

ImportError: cannot import name 'main'

上網(wǎng)搜索了大部分解決辦法都不行,可能環(huán)境和版本都有差異吧。

解決辦法

我的 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) 后,準(zhǔn)備 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

在加了權(quán)限和嘗試各種方法后,解決辦法

以上,問題都解決了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容