Help with package paths
I've been beating my head against a wall trying to figure out how to use packages downloaded with pipista. I've grabbed packages that others have used in pythonista. My question is how can I set the paths so they can be imported?
If I place the source folder directly into Documents it seems to work. However I would really like to have a folder that contains my downloaded packages. I know pipista creates pypi-modules but I do not seem to be able to include the modules inside that folder in other projects.
Any help and/or a basic explination would be most helpful.
https://docs.python.org/2.7/library/sys.html#sys.path is where Python will look for packages to import.
@ccc I had read those threads. It looks like sys.path doesn't save the path when pythonista is reloaded. Would a work around be to have a path module that would be imported before other scripts to set up the module directory?
Just modify the sys.path before your import statements like Ole does in his code snippet in the middle URL above.
@ccc is it possible to add a .pth file to Documents and have it auto load the sys.paths? Reading the documentation it apears it should work becuase /Documents is in the sys.path. but I'm not having any luck. To setup my module path I am currently using a editor action but it would be great if I could just auto load them.
@briarfox Not possible, sorry. In 1.5, there will be a site-packages directory though.
@omz. Sounds likea a great new feature can't wait.
Well I made a little work around action script. I created a site-packages folder and this script will all the contents to sys.path. Just click and run it to import modules
home = os.getenv('HOME')+'/Documents/site-packages/'
modules = [home + name for name in os.listdir(home) if not home+name in sys.path]
@omz Thanks for the upcoming site-packages folder