Change PYTHONPATH in a shell

I am a completely new user in Python and shell scripts, and have run into a dead end even after Google figured out the problem and hit my head hard on the table. Any help is appreciated!

I run Python 2.7.3 on a shell into which I embed SSH; I downloaded some code to run several programs / analyzes. When I execute the initial program, I get the following error:

    Traceback (most recent call last):
    File "./[script1].py", line 7, in <module>
    import [script1]
    File "[directory]/[script].py", line 22, in <module>
    import gdata.spreadsheet.service
    ImportError: No module named gdata.spreadsheet.service

[Script 1] refers to a python script in the same folder that is included as part of the code package, and also calls the python Google Data package, which I downloaded to the same folder, and gunzipped, tar unpacked, and then installed (c. / Configure etc.). Based on the search for errors, I think that something is wrong with PYTHONPATH, and it does not find [script1] .py and the Gdata folder, although both are in the same directory as the script. "Echo $ PYTHONPATH" tells me that this is an undefined variable as well as an empty init .py file in the directory. There are no files inside this directory containing the word "bash" or "bashrc". Likewise, I cannot find the "sys.path" files, although when I load Python and type (sys.path) I get the resulting output:

['', 
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
'/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']

I also tried

export PYTHONPATH=[directory]

, "export: command not found".

, - ( , ), !

+5
1

PYTHONPATH

export, , , bash. , . , (PYTHONPATH) .

PYTHONPATH script ( (T) CSH):

PYTHONPATH=your_directory python script_name

env PYTHONPATH=your_directory python script_name

, PYTHONPATH

, PYTHONPATH Python, script, , python script_name, python -c 'import os; print os.getenv("PYTHONPATH")'. PYTHONPATH.

, sys.path Python PYTHONPATH .

PYTHONPATH

PYTHONPATH, , Python , gdata.

cd path_which_has_subdirectory_gdata
python

Python gdata:

import gdata

, , ImportError:

import gdata.spreadsheet.service

Python, , - [script1]. , , gdata , . __init__.py, PYTHONPATH .

+6

All Articles