다른 폴더의 파일 import

동일폴더의 파일 import

import a.py


상위 폴더의 파일 import

sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
import a.py


시스템 환경변수 추가

$ vi ~/bash_profile

========= bash_profile =========
...
PYTHONPATH=$PYTHONPATH:/home/user/test
export PYTHONPATH
============================
$ source ~/bash_profile

Leave a comment