I have the same Python package installed in many different locations in Mac OS. Due to specific reasons, I want to import the module from a specific installed directory.
Can anyone suggest the best way for doing this?
I have the same Python package installed in many different locations in Mac OS. Due to specific reasons, I want to import the module from a specific installed directory.
Can anyone suggest the best way for doing this?
You can also do something like this and add the directory that the configuration file is sitting in to the Python load path, and then just do a normal import, assuming you know the name of the file in advance, in this case "config".
Messy, but it works.
configfile = '~/config.py'
import os
import sys
sys.path.append(os.path.dirname(os.path.expanduser(configfile)))
import config