강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

psyduck0220님의 프로필 이미지
psyduck0220

작성한 질문수

프로그래밍 시작하기 : 파이썬 입문 (Inflearn Original)

Module(2-2)

module 경로 추가와 sys를 import하는 것의 연관성

작성

·

166

0

module 경로를 추가함에 있어서 sys와의 연관성이 궁금합니다. sys는 무엇이며, module 경로를 왜 sys의 경로에 추가하는 것인지, module 경로를 추가하는 방법이 위와 같은 방법 밖에는 없는지 궁금합니다.

답변 1

0

좋은사람님의 프로필 이미지
좋은사람
지식공유자

파이썬에서는 python path 에서부터 import 된 모듈들을 sys.path 경로등을 토대로 의존관계가 되는 패키지 들을 검색합니다.

물론, 임의대로 패키지가 있는 경로를 추가해서 사용할 수 있습니다.

sys.path = '추가경로'

https://leemendelowitz.github.io/blog/how-does-python-find-packages.html

path in the Python docs. Assuming your PYTHONPATH environment variable is not set, syspath will consist of the current working directory plus any manipulations made to it by the site module. The site module is automatically imported when you start Python, you can read more about how it manipulates your sys.

psyduck0220님의 프로필 이미지
psyduck0220

작성한 질문수

질문하기