Tech Stock logo Tech Stock

MAC기준으로 작성.

youtube-dl로 강의 영상을 몇개 다운로드 하려고 했는데
오랜만에 작동시킨 파이썬이 모듈에러다.. ㅠㅠ
ModuleNotFoundError 발생 ㅠㅠ

파이썬을 잘 알지 못하는 자.. 라서 고생좀 했다.

  1. 인코딩이 어쩌구 저쩌구 나온다.
    # -*- coding: utf-8 -*-
    

    요거를 py파일 젤 위에 추가해본다.

  2. python 실행후
    >>>import sys
    >>>sys.path
    

    이렇게 쳐보면 파이썬이 바라보는 패키지쪽 디렉토리 정보가 나오는데
    그것이 불일치 할경우 (바라보는 패키지와 youtube-dl이 안맞아서) 모듈에러가 난다
    이것을 맞춰줘 본다.

  3. youtube-dl을 지우고 다시 깔아본다
    brew uninstall youtube-dl
    

    후에

    brew install youtube-dl
    

설치시의 내용들

~/Desktop/youtube-dl $ brew install youtube-dl
==> Downloading https://homebrew.bintray.com/bottles/youtube-dl-2021.3.3.big_sur.bottle.tar.gz
Already downloaded: /Users/helloworld/Library/Caches/Homebrew/downloads/d963c76e856140f8eb93eb28ea2e4ddad94b71c10b11992f8d9a0a7511f027c1--youtube-dl-2021.3.3.big_sur.bottle.tar.gz
==> Pouring youtube-dl-2021.3.3.big_sur.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink etc/bash_completion.d/youtube-dl.bash-completion
Target /usr/local/etc/bash_completion.d/youtube-dl.bash-completion
already exists. You may want to remove it:
  rm '/usr/local/etc/bash_completion.d/youtube-dl.bash-completion'

To force the link and overwrite all conflicting files:
  brew link --overwrite youtube-dl

To list all files that would be deleted:
  brew link --overwrite --dry-run youtube-dl

Possible conflicting files are:
/usr/local/etc/bash_completion.d/youtube-dl.bash-completion
/usr/local/bin/youtube-dl
/usr/local/share/man/man1/youtube-dl.1
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/youtube-dl/2021.3.3: 1,391 files, 13.4MB
~/Desktop/youtube-dl $ 

이부분에 주목 (적절히 조치해준다)

already exists. You may want to remove it:
  rm '/usr/local/etc/bash_completion.d/youtube-dl.bash-completion'

To force the link and overwrite all conflicting files:
  brew link --overwrite youtube-dl

To list all files that would be deleted:
  brew link --overwrite --dry-run youtube-dl

Possible conflicting files are:
/usr/local/etc/bash_completion.d/youtube-dl.bash-completion
/usr/local/bin/youtube-dl
/usr/local/share/man/man1/youtube-dl.1

어디에 깔렸는지 어떤 문제가 있는지 나오는 내용을 잘 확인하고 조치한다.


마지막으로 파이썬을 다시 깔아본다.

brew uninstall python3

후에

brew install python3

인스톨시의 내용

~/Desktop/youtube-dl $ brew install python3
==> Downloading https://homebrew.bintray.com/bottles/python%403.9-3.9.2_1.big_sur.bottle.tar.gz
Already downloaded: /Users/helloworld/Library/Caches/Homebrew/downloads/812addf569674782d8f470fcc4db3abc5f0e1abb854008843ddcc383cce0b614--python@3.9-3.9.2_1.big_sur.bottle.tar.gz
==> Pouring python@3.9-3.9.2_1.big_sur.bottle.tar.gz
==> /usr/local/Cellar/python@3.9/3.9.2_1/bin/python3 -m ensurepip
==> /usr/local/Cellar/python@3.9/3.9.2_1/bin/pip3 install -v --global-option=--no-user-cfg --install
==> /usr/local/Cellar/python@3.9/3.9.2_1/bin/pip3 wheel --wheel-dir=/usr/local/Cellar/python@3.9/3.9
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python@3.9/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.9/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
🍺  /usr/local/Cellar/python@3.9/3.9.2_1: 3,935 files, 65.9MB

이부분에 주목

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.9/site-packages

패키지 디렉토리가 어디인지 어디에 깔렸는지 어떤 문제가 있는지 나오는 내용을 잘 확인하고 조치한다.

대충 이정도로 정리해볼 수 있겠다. 조금더 필요한 정보들은 구글선생님께 물어봐서 후다닥 조치하자..
시간 잡아먹는 하마가 되지 말것 ㅜㅜ