I've copied a few modules from the standard site-packages location on my windows pc into an EC2 ubuntu instance's user's home directory: /home/theuser/data/projects/mypack.
mypack contains
1) one empty __init__.py and
2) one subdirectory mymodules, in which I have my python module files along with one __init__.py that runs the from thefile import thefile statements.
I've made sure to edit both .bashrc and .profile for theuser in order to update PYTHONPATH. And I made sure to start a fresh session, logged in as theuser.
import mypack runs fine if I'm in /home/theuser/data/projects. Anywhere else, say in theuser's home directory, I get
>>> import mypack
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mypack
I'm not that familiar with unix permissions, and the setup above tested OK on my pc. Is some unix permission detail tripping me up?
PYTHONPATH does seems to register the change properly:
>>> import sys
>>> print sys.path
['',
'/usr/local/lib/python2.7/dist-packages/distribute-0.6.48-py2.7.egg',
'/home/theuser',
'/home/theuser/data/projects/mypack',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages']
Thanks.
theuser@ip-12-345-67-8:~/data/projects$ ls -lah
total 20K
drwxrwxr-x 5 theuser theuser 4.0K Jul 2 18:50 .
drwxr-xr-x 5 theuser theuser 4.0K Jul 2 16:48 ..
drwxrwxr-x 2 theuser theuser 4.0K Jul 2 17:18 database
drwxrwxr-x 2 theuser theuser 4.0K Jul 2 18:28 analysis
drwxrwxr-x 5 theuser theuser 4.0K Jul 2 19:18 mypack
ls -lahinside /home/theuser/data/projects?python -m site --user-site). It's in sys.path by default, so spares you to mess around with PYTHONPATH, .profile and .bashrc...