python and FSO MS 2 questions

Alon Levy alonlevy1 at gmail.com
Fri Aug 15 22:00:44 CEST 2008


You need to have a __init__.py file for python to look at the directory as a
module. So basically:

/home/me/pythondir/__init__.py
/home/me/pythondir/file1.py
/home/me/pythondir/file2.py
...
PYTHONPATH=$PYTHONPATH:/home/me/pythondir

then you can
python -c "import file1"

__init__.py can contain nothing, easiest way to create it is with touch:

touch /home/me/pythondir/__init__.py

But yes, you should just look at the python docs - try:
http://docs.python.org/tut/node8.html#SECTION008400000000000000000

Alon

On Fri, Aug 15, 2008 at 10:29 PM, C R McClenaghan <chris at mcclenaghan.com>wrote:

> I thought I'd try some different things and learn python along the way.
>
> I have FSO MS 2 installed with opkg feeds updated and including the
> angstrom repository feed.
>
> I don't seem to be able to install python packages which appear in the
> angstrom repository, although I have installed other non-python
> packages from angtrom - e.g., libnotify, etc., for the the alpha 2
> version of gestures working. Perhaps there is something about opkg I
> don't understand. I added a base-feeds.conf  per the instructions here
> http://wiki.openmoko.org/wiki/Repositories
> .
>
> With respect to python, I'm assuming that I can install any python
> package/file I choose and it need not come through the opkg system,
> just drop the *.py file(s) where it can be found. Now that leads to
> what is probably simply a python question, but I'll ask it anyway,
> what is the proper way to set PYTHONPATH such that a new directory of
> python files will be found? I tried:
>
> PYTHONPATH=$PWD
>
> where the files were in my current directory and the import statements
> still failed.
>
> Thanks,
>
> Chris
>
> _______________________________________________
> support mailing list
> support at lists.openmoko.org
> https://lists.openmoko.org/mailman/listinfo/support
>



-- 
Alon Levy
http://wiki.saymoo.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openmoko.org/pipermail/support/attachments/20080815/11974cd5/attachment.htm 


More information about the support mailing list