Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to import python module from file path

#: say you you wanted to load/import the module 'bla.py'
#: that's sitting inside the directory '/Path/To/Modules/Dir/'
#: on your system. to have it available for import on every run
#: of the python interpreter (i.e permentantly), add the path
#: this directory to the $PYTHONPATH environment variable that
#: the Python interpreter recognizes:

export PYTHONPATH="${PYTHONPATH}:/Path/To/Modules/Dir/"

python3 -c "
import bla
"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #import #python #module #file #path
ADD COMMENT
Topic
Name
2+3 =