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

    Join Date
    May 2004
    Posts
    27
    Rep Power
    0

    Exclamation how to set $PYTHONPATH environment variable?


    Hello ,

    what i want to do is, update search path of pytho. so if i add new module in python, i can use it in another python script.

    Any idea????


    Thanks.

    DevHims
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,624
    Rep Power
    4247
    Depends on the shell you're using. You might want to tell us that first.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    If your on a windows (tested on XP) box you can simply right click 'my computer' and right down at the bottom you should see 'properties'. In theres thers a tab called 'adanvced' which when clicked give you a button at the bottom, If you click that it should bring up a little widget with some input boxes etc. I believe you just add it in there.

    Hope this is of some help,

    Mark.
    programming language development: www.netytan.com Hula

  6. #4
  7. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Alternatively - just copy the module into a location already defined by PYTHONPATH.

    Into site-packages for example.

  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Alternativly you can do this intirly in Python using the sys module i.e.

    Code:
    #!/usr/bin/env python
    
    import sys
    
    sys.path.append('path/to/my/modules/')
    
    import my_module
    You can also in theory use .pth files to do this though i've only got this working inside the site-packages directory.

    Mark.
    programming language development: www.netytan.com Hula

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Location
    Bimingham,AL
    Posts
    68
    Rep Power
    11
    In windows:
    go to sytem properties -> advanced create a new variable called PYTHONPATH and give it the path where u want to put your files.
    And don't forget to put __init__.py file in your directory.
    go to the following link for more details:
    http://docs.python.org/tut/node8.html

IMN logo majestic logo threadwatch logo seochat tools logo