Results 1 to 5 of 5

Thread: Finding & Defining the PYTHONPATH

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Location
    Somewhere in rural Ohio
    Beans
    17
    Distro
    Xubuntu 7.04 Feisty Fawn

    Finding & Defining the PYTHONPATH

    Alright, here's my question. In order to import modules, someone whom I thank greatly, told me to find and modify the PYTHONPATH file; the problem is, I don't even begin to known the commands in the python interpreter to even begin that, can someone help?

  2. #2
    Join Date
    Jun 2006
    Location
    CT, USA
    Beans
    5,267
    Distro
    Ubuntu 6.10 Edgy

    Re: Finding & Defining the PYTHONPATH

    on ubuntu? all is set up.

    To try, check how to start page.

    In short: At command propmt, type:

    > python

    (python shell will start, with >>>)
    >>> import cgi
    If no error messages, you are in. If not, post massages here.

  3. #3
    Join Date
    Jun 2007
    Location
    Edinburgh Scotland
    Beans
    260
    Distro
    Xubuntu 11.04 Natty Narwhal

    Re: Finding & Defining the PYTHONPATH

    Put this in your .basgrc

    Code:
    export PYTHONPATH=$PYTHONPATH:<my pythonpath>
    Where <my pythonpath is, for example /home/user_name/python_files
    Where python_files is the directory containing the .py files you want to import

    Cheers
    I laughed, I cried, I jumped with joy. I was here before Killroy. 8)

  4. #4
    Join Date
    Feb 2008
    Beans
    1

    Re: Finding & Defining the PYTHONPATH

    Make a backup of the file: .profile
    then add this line to the file: .profile

    export PYTHONPATH=/home/steve/Documents

    if your username=steve
    and the directory you want added is /home/steve/Documents

    On the other hand, if the username=Frank
    and you want to add the Music directory
    then add this line to the file: .profile

    export PYTHONPATH=/home/Frank/Music

    Also, note that the file (.profile) is a hidden file.
    You may have to click on VIEW then SHOW HIDDEN FILES
    within Nautilus to access hidden files.
    Also, the file: .profile is found in the Home Folder

    Reference Links:
    https://help.ubuntu.com/community/EnvironmentVariables
    http://docs.python.org/lib/module-sys.html
    http://ubuntuforums.org/showthread.php?t=2793

    peace

  5. #5
    Join Date
    Aug 2006
    Beans
    366

    Re: Finding & Defining the PYTHONPATH

    It is normally done in the program itself. Directories added to the $PYTHONPATH variable are ones that you access all of the time.

    import sys
    sys.path.append("/path_to/module/")
    import the_program ## can now be found in the dir /path_to/module/
    Linux Counter entry # 99383 (since 1995), Feisty Xbuntu 64 bit
    Folders! We don't need no stinking folders. "I don't have anything on my machine that needs folding" -- Unknown

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •