This is what I use:
import os, sys
sys.path.append(os.path.join(os.path.dirname(__file__), "lib"))
More Related Contents:
- How do I unload (reload) a Python module?
- How can I import other Python files?
- Import a module from a relative path
- Sibling package imports
- How to load all modules in a folder?
- ImportError: No module named requests
- Circular import dependency in Python
- How to mock an import
- Trying to import module with the same name as a built-in module causes an import error
- Callable modules
- List all the modules that are part of a python package?
- Importing modules: __main__ vs import as module
- ModuleNotFoundError: What does it mean __main__ is not a package?
- How can I check if a module has been imported?
- Dynamic loading of python modules
- python packaging for relative imports
- Cyclic module dependencies and relative imports in Python
- Python Nose Import Error
- Prevent Python from caching the imported modules
- What happens when using mutual or circular (cyclic) imports?
- How can I import a module dynamically given its name as string?
- Pillow installed, but getting “no module named pillow” when importing
- Reading a file using a relative path in a Python project
- how to “reimport” module to python then code be changed after import
- Hide external modules when importing a module (e.g. regarding code-completion)
- Python import error: cannot import name ‘six’ from ‘sklearn.externals’
- Importing module from string variable using “__import__” gives different results than a normal import statement
- How to reference python package when filename contains a period
- Recursive version of ‘reload’
- How to add a Python import path using a .pth file