pipenv 환경에서 mysqlclient를 설치하려다 만난 에러들을 해결한 내용을 정리한다.

pipenv install mysqlclient

ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'xcrun' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mysqlclient
ERROR: Command errored out with exit status 1:
  • xcrun을 못찾아서 발생한 에러다.
  • xcrun이란 xcode에서 사용하는 스크립트 실행 명령어로, xcode를 사용하지 않더라도 mac OS를 사용하는 경우 종종 사용된다.
  • xcode-select --install를 수행하면 해결되지만, 다음과 같은 에러를 또 만날 수 있다.
    xcode-select: error: command line tools are already installed, use "Software Update" to install updates

xcode-select: error: command line tools are already installed, use "Software Update" to install updates 해결 방법

  • https://developer.apple.com/download/all/
  • 위 링크에서 자신의 mac OS보다 낮거나 같은 버전의 Command Line Tools를 설치해준다.
  • 필자의 경우 10.15 버전의 mac OS를 사용중이어서, 10.15로 검색했지만 아무것도 나오지 않았다.
  • 그래서 10.14로 검색하니 다음과 같이 호환되는 버전이 나와서 해당 버전으로 설치했다.
    image
  • xcode를 사용하지 않는 필자로썬 뒤에 for Xcode가 거슬리지만, 무시하고 설치하자.

설치 후

  • 설치하고 나면 기존에 사용중인 개발 환경에서 몇몇 변화가 있을 수 있다.
  • 필자의 경우
    • pipenv관련 설정이 날라가거나 초기화되었다.
    • 기본 python3 사용 버전이 3.7이었는데, 3.9로 업데이트되었다.
  • 다음과 같이 해결했다.
    • zsh를 사용하고 있었기 때문에, ~/.zshrc에 다음 설정을 추가했다.
      export PYENV_ROOT={python3 기본 경로} // $ whereis python3의 결과
      export PIPENV_PYTHON=$PYENV_ROOT/shims/python
    • Pipfile에서 python 3.7버전을 사용중이었지만, 3.9로 수정해주었다.
  • 이후 pipenv 환경 삭제 후 재생성해주었다.

원래 하려던 건 mysqlclient 설치였다.

  • 참 길게 돌고돌았다. 이제 다음 명령을 수행해보자.
    $ pipenv install mysqlclient
    ... ✔ Success! ...
  • mysqlclient 설치가 완료되었다.

+ Recent posts