#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    154
    Rep Power
    14

    sys.path problem


    I'm writing a python script which needs to read a package from a directory currently not known by python. I've simply appended the path to the sys module, then called the module in question, but on running, the package fails to be found. Here's the code I'm using:

    #!/usr/bin/python

    import sys

    sys.path.append('/home/csunix/extras')

    import nltk #package located in above appended directory



    Any ideas where I'm going wrong???
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Permissions could be the problem.

    When you say package do you mean module as in nltk.py
    or that nltk is a sub-directory of /home/csunix/extras conforming to the Python package format (it has a __init__.py file).

    grim
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    154
    Rep Power
    14
    Sorted. I did not reference the correct sub-directory containing the _init_.py


    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo