python - Importing a custom module from a different directory within the same project -
i'm trying import custom module reason can't work , i'm getting importerror.
my directory structure so:
myproject - myproject - bin scraper.py - myproject __init__.py custommodule.py - web index.html - venv i'm attempting import custommodule.py scraper.py. ideally without having set environment variables, or using sys.path.
this i've tried:
import custommodule myproject import custommodule ..myproject import custommodule is possible?
taking jean-françois fabre's comment account, if no solution without sys.path provided, consider using:
import sys import os sys.path.append(os.path.join(os.path.dirname(__file__),'..','myproject')) import custommodule
Comments
Post a Comment