윈도우에서 WSL2 환경으로 파이썬 개발을 하다보면 새로운 모듈을 설치해야할 경우가 있다. 이 때, pip install 명령을 사용하게 되는데 먹통이 되는 경우가 있다.
$ pip install requests
^CTraceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3/dist-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 19, in <module>
from pip._internal.network.session import PipSession
File "/usr/lib/python3/dist-packages/pip/_internal/network/session.py", line 26, in <module>
from pip._internal.network.auth import MultiDomainBasicAuth
File "/usr/lib/python3/dist-packages/pip/_internal/network/auth.py", line 36, in <module>
import keyring # noqa
File "/usr/lib/python3/dist-packages/keyring/__init__.py", line 3, in <module>
from .core import (
File "/usr/lib/python3/dist-packages/keyring/core.py", line 189, in <module>
init_backend()
File "/usr/lib/python3/dist-packages/keyring/core.py", line 93, in init_backend
keyrings = filter(limit, backend.get_all_keyring())
File "/usr/lib/python3/dist-packages/keyring/util/__init__.py", line 21, in wrapper
func.always_returns = func(*args, **kwargs)
File "/usr/lib/python3/dist-packages/keyring/backend.py", line 210, in get_all_keyring
return list(rings)
File "/usr/lib/python3/dist-packages/keyring/util/__init__.py", line 31, in suppress_exceptions
for callable in callables:
File "/usr/lib/python3/dist-packages/keyring/util/properties.py", line 26, in __get__
return self.fget.__get__(None, owner)()
File "/usr/lib/python3/dist-packages/keyring/backend.py", line 67, in viable
cls.priority
File "/usr/lib/python3/dist-packages/keyring/util/properties.py", line 26, in __get__
return self.fget.__get__(None, owner)()
File "/usr/lib/python3/dist-packages/keyring/backends/SecretService.py", line 34, in priority
bus = secretstorage.dbus_init()
File "/usr/lib/python3/dist-packages/secretstorage/__init__.py", line 47, in dbus_init
return dbus.SessionBus()
File "/usr/lib/python3/dist-packages/dbus/_dbus.py", line 212, in __new__
return Bus.__new__(cls, Bus.TYPE_SESSION, private=private,
File "/usr/lib/python3/dist-packages/dbus/_dbus.py", line 102, in __new__
bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 124, in __new__
bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
File "/usr/lib/python3/dist-packages/dbus/exceptions.py", line 47, in __init__
def __init__(self, *args, **kwargs):
KeyboardInterrupt
Hang 상태에서 [Ctrl] + c 로 명령을 취소하면 이런 콜스택을 찍고 종료된다.
해결방법
WSL2에서 pip를 실행하면 XServer에 연결시도를 하는 경우가 있다. 이 경우 DISPLAY 환경 변수를 초기화하면 먹통이 되지 않고 정상적으로 실행된다.
$ export DISPLAY=
$ pip install requests
댓글