BE개발 - python 가상환경 설정

이진규·2022년 12월 17일
0

문제

가상환경을 설정하기 위해 pipenv를 설치하고 실행했더니 오류가 났다.

C:\Users\hippo>pipenv
'pipenv'() 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는
배치 파일이 아닙니다.

구글링을 해봤더니 virtualenv와 pipenv가 버전 충돌이 나서 그런거고 재설치하면 될거라고 했다. 그런데도 해결이 되지 않았다.

C:\Users\hippo>pipenv
'pipenv'() 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는
배치 파일이 아닙니다.

왜그럴까 생각해봤는데 pip install을 하던 중 경고 에러가 났던 것이 생각났다. 경고라서 그냥 무시했는데, 읽어보니 경로추가를 하라는 에러였다.

WARNING: The script virtualenv-clone.exe is installed in 'C:\Users\~~~\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script virtualenv.exe is installed in 'C:\Users\~~~\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts pipenv-resolver.exe and pipenv.exe are installed in 'C:\Users\~~~\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

그래서 시스템 환경변수 Path에 위의 경로를 추가하고 cmd를 다시 열었더니 실행됐다.

Django Rest Framework의 구축을 설명한 글에서 타입 힌트 기능이 있는 파이썬3.8을 사용한다고 했기에 나도 파이썬 3.8버전을 사용하기로 했다.

pipenv --python 3.8

이제 가상환경 설정 끝!

profile
개발자

0개의 댓글