0
泊塢窗SDK時,爲了使用Docker SDK for Python無模塊命名ssl_match_hostname,我想import docker
在Python腳本,但它造成的ImportError
有以下追蹤:導入錯誤:導入的Python
Traceback (most recent call last):
File "/home/kurt/dev/clones8/ipercron-compose/furion/iclib/tests/test_utils/docker_utils.py", line 1, in <module>
import docker
File "/home/kurt/.local/lib/python2.7/site-packages/docker/__init__.py", line 6, in <module>
from .client import Client, AutoVersionClient, from_env # flake8: noqa
File "/home/kurt/.local/lib/python2.7/site-packages/docker/client.py", line 11, in <module>
from . import api
File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/__init__.py", line 2, in <module>
from .build import BuildApiMixin
File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/build.py", line 9, in <module>
from .. import utils
File "/home/kurt/.local/lib/python2.7/site-packages/docker/utils/__init__.py", line 2, in <module>
from .utils import (
File "/home/kurt/.local/lib/python2.7/site-packages/docker/utils/utils.py", line 19, in <module>
from .. import tls
File "/home/kurt/.local/lib/python2.7/site-packages/docker/tls.py", line 5, in <module>
from .ssladapter import ssladapter
File "/home/kurt/.local/lib/python2.7/site-packages/docker/ssladapter/__init__.py", line 1, in <module>
from .ssladapter import SSLAdapter # flake8: noqa
File "/home/kurt/.local/lib/python2.7/site-packages/docker/ssladapter/ssladapter.py", line 21, in <module>
from backports.ssl_match_hostname import match_hostname
ImportError: No module named ssl_match_hostname
[Finished in 0.2s with exit code 1]
[shell_cmd: python -u "/home/kurt/dev/clones8/ipercron-compose/furion/iclib/tests/test_utils/docker_utils.py"]
[dir: /home/kurt/dev/clones8/ipercron-compose/furion/iclib/tests/test_utils]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
奇怪的是,進口不會在其他地方工作,例如在IPython的提示:
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import docker
In [2]:
爲什麼沒有在第一種情況下工作的意義是什麼?
你有2個版本的Python的遵守?你有沒有嘗試在python3中安裝'docker'? f.e.,'pip3 install docker'? – Dmitry
我確實有2個版本的Python,但據我所知,我還沒有嘗試過'pip3 install docker'。 –