I am tinkering with some pet projects with Python in Linux (Mint 13) and I plan to do the following:
- Create a Dropbox subfolder named “pybin” where I put all my home-made python modules;
- Put a symlink to this folder somewhere in the system (first candidate:
/usr/lib/python2.7/dist-packages, which is insys.path, or some similar path); - Then I just do
import mymodulefrom any python session, and the module is imported.
I tried it and it didn’t work. I suspect this has to do with differences between modules and packages, and __init__.py files, but I confess that everytime I read something about this stuff I get pretty confused. Besides learning a bit more about this, all I really want to do is find a way to import my modules the described way. It is crucial that the actual folder is inside Dropbox (or any other file-syncing folder), not in a system folder.
Thanks for any help!
Why not simply set the PYTHONPATH envvar in your .bash_profile. That way every time you execute a bash shell (normally happens upon login), this environment variable will be set the wherever you place your user defined modules. The python interpreter uses this variable to determine where to search for module imports: