I have cloned a python library xyz
into my computer. The file structure is as follows:
>> project (folder)
* main.py
>> xyz_git (folder)
>> xyz (folder)
In the main.py
import sys
sys.path.insert(0, './xyz_git')
from xyz import Xyz
instance = Xyz()
print(instance.some_function())
The problem is I also have pip-installed module xyz
to default python. Even if I remove the local folder, the from xyz import Xyz
will still work due to the default pip installation. How can I ensure if the xyz
import is not from local directory, it will give an error?