개발로 자기계발
728x90

파이썬 3.8 버전으로 venv를 생성하려다가 에러를 만났다.

Error: Command '['/home/ubuntu/pica_team/pica_proj/pica_venv/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

 

1) pip 없이 가상환경 생성

python3.8 -m venv venv --without-pip

 

2) 가상환경 활성화

source venv/bin/activate

 

3) pip 파일 받아오기

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

 

4) pip 설치

python get-pip.py

* 근데 여기서 이런 에러가 발생했다면?

Traceback (most recent call last):
  File "get-pip.py", line 32321, in <module>
    main()
  File "get-pip.py", line 135, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 111, in bootstrap
    monkeypatch_for_cert(tmpdir)
  File "get-pip.py", line 92, in monkeypatch_for_cert
    from pip._internal.commands.install import InstallCommand
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp8g59trjl/pip.zip/pip/_internal/commands/__init__.py", line 9, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp8g59trjl/pip.zip/pip/_internal/cli/base_command.py", line 15, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp8g59trjl/pip.zip/pip/_internal/cli/cmdoptions.py", line 24, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp8g59trjl/pip.zip/pip/_internal/cli/parser.py", line 12, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp8g59trjl/pip.zip/pip/_internal/configuration.py", line 26, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp8g59trjl/pip.zip/pip/_internal/utils/logging.py", line 29, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp8g59trjl/pip.zip/pip/_internal/utils/misc.py", line 44, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp8g59trjl/pip.zip/pip/_internal/locations/__init__.py", line 66, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp8g59trjl/pip.zip/pip/_internal/locations/_distutils.py", line 20, in <module>
ModuleNotFoundError: No module named 'distutils.cmd'

가상환경 비활성화

deactivate

모듈 설치

sudo apt-get install python3.8-distutils

 

그리고 나서 위 과정을 다시 하게 되면 에러 없이 가상환경을 생성할 수 있다.

728x90
SMALL
profile

개발로 자기계발

@김잠봉

틀린부분이나 조언이 있다면 언제든 환영입니다:-)