Page 1 of 2
Python Modules
Posted: Mon Dec 10, 2012 7:23 pm
by jawknee
Hi all. I'd like to be able to use the python dateutils module, but I can't find it. Is there a place where some of these modules live? Is there a way to install them otherwise?
thanks,
-Johnny
Re: Python Modules
Posted: Tue Dec 11, 2012 4:01 pm
by joemuller
Johnny,
Is there a particular function that isn't working for you? The following seems to work on both the shell and web cluster:
Code: Select all
#!/usr/bin/python
from datetime import *
NOW = datetime.now()
TODAY = date.today()
print NOW
print TODAY
-- Joe
Re: Python Modules
Posted: Tue Dec 11, 2012 4:51 pm
by jawknee
Hey Joe - thanks for the reply...
Basically time zones and conversion to/from UTC / local time. I'm still fairly new to python, but the research I've done has indicated that either dateutils or pytz is required to do this well - I coded to dateutils.
I'm hoping to run some of the scripts in a cgi-bin context.
thanks,
-Johnny
Re: Python Modules
Posted: Fri Dec 14, 2012 11:33 am
by joemuller
My recommendation is to load the python modules from a local (relative to website) directory. A good guide on how to do so can be found at:
http://stackoverflow.com/questions/2792 ... m-a-folder
I haven't fully tested it, but if you have the right files, you should be able to import the missing modules from you own copies.
Re: Python Modules
Posted: Fri Dec 14, 2012 11:40 am
by jawknee
Joe - excellent, I'll definitely check that out.
thanks!
-Johnny
Re: Python Modules
Posted: Thu Mar 28, 2013 2:43 pm
by jawknee
Joe - thanks again for the reply. I've been working on other aspects of my project but I finally got back to this. It turns out the dateutil module is so tiny I can easily include it in my local dir.
But not so the Python Image Library: PIL. For that I used your recommendation and that is working, but...
PIL requires a setup step that has to compile bits of C code. That's failing for me with:
$ python setup.py install
running install
error: invalid Python installation: unable to open /usr/include/python2.6/pyconfig.h (No such file or directory)
---
The /usr/include/python2.6/ dir is empty.
I'm guessing I'm stuck at this point (I don't have acces to a 2.4 linux machine or I'd attempt to cross compile).
If you have any idea how I can proceed, that's be great. In any case - thanks for the pointer on the path.
-jk
Re: Python Modules
Posted: Fri Mar 29, 2013 9:15 am
by joemuller
I do like a good puzzle! :-p Placing a properly-generated version of the pyconfig.h file did help move things along further, but the version of gcc on shell appears to possibly be too old to work. :-/
I'll see if I can hack at it a bit further this weekend.
Re: Python Modules
Posted: Fri Mar 29, 2013 10:19 am
by jawknee
My hero! I noted there is still nothing in /usr/include/python2.6/ on shell.sonic.net so I'm guessing you're working in a different context? In any case, this would be cool - be nice not to have to run home to update the links.
-jk
Re: Python Modules
Posted: Mon Apr 15, 2013 4:27 pm
by jawknee
Joe - any further luck? Anything I can do to help?
Re: Python Modules
Posted: Mon Apr 15, 2013 5:28 pm
by joemuller
Well, I managed to get it to work under Python 2.3.4:
1.) Download the latest PIL source package (
http://effbot.org/media/downloads/PIL-1.1.7.tar.gz)
2.) Unpack it (tar xzf PIL-1.1.7.tar.gz)
3.) Attempt to perform an in-place build (from the extracted directory, run: python setup.py build_ext -i)
4.) Verify it works by running 'python selftest.py' from the same directory.
5.) Copy the subfolder in the build directory to a location of your choosing, than make sure python knows to load extensions from there.
6.) ???
7.) Profit!