problem with crontab on copmuter with two python version

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • noama
    New Member
    • Aug 2007
    • 9

    problem with crontab on copmuter with two python version

    Hi,
    I'm using a computer with a Linux CentOS Operating system, which uses python 2.3 and known to break if python is upgraded to 2.5. Since i need to run 2.5 scripts on that machine, some people in a linux forum recommended to compile 2.5 on that machine and have two python interpreters installed. so now, when i type "python" i still get the 2.3 version, and when i type "python2" i get the new version. to make sure it works i created a simple script called CheckVersion.py :
    Code:
    import sys
    print sys.version
    when run with python2 it outputs that the version is 2.5 and when run using "python" it outpus 2.3. so far so good. but, when i set up a crontab job:
    * * * * * python2 CheckVersion.py > /usr/local/testLog
    suddenly i see that somehow the output is that of the 2.3 version...
    why is that? the only thing i can think of is that somehow because crontab has different PATH vars the python2.5 interpreter imports the 2.3 sys module... but that sounds rather odd. any ideas?
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    On Windows there's an environment variable called PYTHONPATH.
    Directories named in that variable are appended to sys.path.
    Check that by:[CODE=python]import sys
    print sys.path[/CODE]

    Comment

    • noama
      New Member
      • Aug 2007
      • 9

      #3
      But how does that make python2.5 use imports of python2.3?

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Originally posted by noama
        But how does that make python2.5 use imports of python2.3?
        There is only one environment variable called PYTHONPATH in a (Windows, anyway) system.
        Both versions would use that to extend their search depth. The way to resolve this is to make sure that the module is question is in the is in the respective site-packages directory and ensure that site-packages is NOT in the environment variable.

        Comment

        Working...