Use modules in the desired path

Use modules in the desired path


sys.path

Paths currently available

import sys
sys.path
['', 
'/opt/conda/lib/python37.zip', 
'/opt/conda/lib/python3.7', 
'/opt/conda/lib/python3.7/lib-dynload', 
'/opt/conda/lib/python3.7/site-packages']

Navigating the paths in order when importing modules. If the module you want to import is not in the list of paths, add the path.

sys.path.append()

import sys
sys.path.append("/mmdetection/mmdetection/")
import sys
sys.path
['', 
'/opt/conda/lib/python37.zip',
'/opt/conda/lib/python3.7', 
'/opt/conda/lib/python3.7/lib-dynload', 
'/opt/conda/lib/python3.7/site-packages', 
'/mmdetection/mmdetection']

If a python module name with the same name as the internal module exists, python will import the other file with the same name instead of the module in the path we want.

sys.path.remove()

sys.path.remove('/mmdetection/mmdetection/src/mmtrack')

When sys.append does not working

reinstall

pip install --no-cache-dir -r requirements/build.txt
pip install --no-cache-dir -e .