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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -