Python で親ディレクトリにあるパスの import
import sys from os import pardir from os.path import dirname from os.path import sep # Step1. 親ディレクトリのパス # pardir_path = /dir_a/dir_b/dir_c/dir_d/.. pardir_path = dirname(__file__) + sep + pardir # Step2. append で親ディレクトリのパスの追加 sys.path.append(pardir_path) import mymodule