How to import custom json module instead of the default in python 2.7?
Question: Assuming my directory structure is:

    
    
    C:\Scripts\myscript.py
    C:\Scripts\customjson\json.py
    

The myscript.py python script has at the top:

    
    
    sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'customjson'))
    import json
    

The thing is, I have a "customjson" folder that contains a json.py that I want
to use instead of the default json package that Python 2.7 comes with. How do
I make it so that the script uses "customjson" instead of the standard json?


Answer: Try to insert your customjson directory first in `sys.path`:

    
    
    sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), 'customjson'))
    import json
    

