You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Up until now, the solution I've been using for importing modules is to require that my scripts are executed from the git repo that they're in (i.e. I use cwd = os.getcwd() when defining the module directory).
It turns out that when you run a script at the command line sys.path[0] will always be the directory that the script is located in, so using that is a better way to do it. e.g.
importsysscript_dir=sys.path[0]
repo_dir='/'.join(script_dir.split('/')[:-1])
module_dir=repo_dir+'/modules'sys.path.append(module_dir)
try:
importtimeseriesimportgeneral_ioasgioimportspatial_weightsexceptImportError:
raiseImportError('Script and modules in wrong directories')
The text was updated successfully, but these errors were encountered:
Up until now, the solution I've been using for importing modules is to require that my scripts are executed from the git repo that they're in (i.e. I use
cwd = os.getcwd()
when defining the module directory).It turns out that when you run a script at the command line
sys.path[0]
will always be the directory that the script is located in, so using that is a better way to do it. e.g.The text was updated successfully, but these errors were encountered: