Dev History

[Poetry] Installation Error ( Permission Denied )

scone 2023. 12. 29. 12:06

https://python-poetry.org/docs/#installing-with-the-official-installer

scone@scone-B650-PG-Lightning:~/boostcamp/week8$ sudo curl -sSL https://install.python-poetry.org | python3 -
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

/home/scone/.local/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (1.7.1): An error occurred. Removing partial environment.
Poetry installation failed.
Traceback (most recent call last):
  File "<stdin>", line 923, in main
  File "<stdin>", line 560, in run
  File "<stdin>", line 581, in install
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "<stdin>", line 653, in make_env
  File "<stdin>", line 639, in make_env
  File "<stdin>", line 352, in make
  File "<stdin>", line 375, in pip
  File "<stdin>", line 372, in python
  File "<stdin>", line 365, in run
__main__.PoetryInstallationError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 945, in <module>
  File "<stdin>", line 930, in main
  File "/usr/lib/python3.8/tempfile.py", line 470, in mkstemp
    return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
  File "/usr/lib/python3.8/tempfile.py", line 389, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
PermissionError: [Errno 13] Permission denied: '/home/scone/boostcamp/week8/poetry-installer-error-bww4yo5w.log'

 

  • sudo로 진행했기 때문에 permission denied 된게 이상해서 error log 를 확인했다.
  File "/home/scone/.local/share/pypoetry/venv/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 66, in <module>
    from . import _distutils
  File "/home/scone/.local/share/pypoetry/venv/lib/python3.8/site-packages/pip/_internal/locations/_distutils.py", line 20, in <module>
    from distutils.cmd import Command as DistutilsCommand
ModuleNotFoundError: No module named 'distutils.cmd'

Traceback:

  File "<stdin>", line 923, in main
  File "<stdin>", line 560, in run
  File "<stdin>", line 581, in install
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "<stdin>", line 653, in make_env
  File "<stdin>", line 639, in make_env
  File "<stdin>", line 352, in make
  File "<stdin>", line 375, in pip
  File "<stdin>", line 372, in python
  File "<stdin>", line 365, in run

 

ModuleNotFoundError: No module named 'distutils.cmd'

 

  • disutils 설치
sudo apt install python3-distutils

 

정상 설치

 

Add export path 부분 까지하면 poetry 설치가 완료되게 된다.

 

참고로 환경 설정은 리눅스의 경우

vi ~/.bashrc

vi ~/.zshrc

 

둘 중 하나에 들어가 (본인이 사용하는 쉘에 따라 다르다.) export PATH 블라블라 의 내용을 추가해주면 된다.

이후 linux 환경에 재로그인해야 환경변수 설정이 반영되는데 source ~/.bashrc (본인 쉘에 따른) 를 할 경우 재로그인 하지 않고도 즉시 반영 된다.