Where to save my custom scripts so that my python scripts can access the module in the default directory?

Viewed 35153

This is going to be a multi-part question but the ultimate aim is such that I can access custom-made modules/libraries/functions like how I do in native python.

Where are the non-native but pip installed python libraries stored and how to configure my interpreter/IDE to access them?

My users' script all starts with:

#!/usr/bin/env python -*- coding: utf-8 -*- 

What's the difference between accessing from /usr/bin and /usr/bin/env, will the custom-made modules that should import like native python modules/packages work?

Should my custom scripts become packages? if so how do I make the user-side code, checks for ImportError and install/setup these packages in the try-except? e.g.

try:
  import module_x
except ImportError:
  # Install package, but how to do it within the script?
  pass

Is there a place to store my custom scripts such that it imports like a native library? If so, where? What are the consequences?

1 Answers
Related