I've installed a module using pip
pip install module_x -i ....
Now I need to add new functions to the module. So updated the source code and did the following in the tests
directory.
Directory and files structure.
api
module_x
files ....
tests
Now I want to test the code in api/tests
:
import sys
sys.path.append('..')
import module_x
dir(module_x)
However, dir(module_x)
still doesn't show any new objects I added? It import module_x
imported the pip installed one. (I added print('...')
in the __init__.py
and nothing was printed after import. How to import the module from local path?
It needs to insert the relative path in front of other path.
import sys
sys.path.insert(0, '..') # insert .. in front of other path
import module_x
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments