Setting PYTHONPATH
By the output of the export
command you tried, it looks like the shell you are using is not bash. This post covers some ways on how to find out which shell you are on. After finding out your shell, you can find out how to set environment variables (PYTHONPATH) in that shell.
You might also try these to set the PYTHONPATH for the duration of running your script (the last one should work on (T)CSH):
PYTHONPATH=your_directory python script_name
and
env PYTHONPATH=your_directory python script_name
Testing that the PYTHONPATH you set works
To see that PYTHONPATH really gets set and works within Python, instead of running the script like above with python script_name
, use python -c 'import os; print os.getenv("PYTHONPATH")'
. It should display the PYTHONPATH you just set.
Likewise, printing sys.path
in Python interpreter should output the path in PYTHONPATH as one of the entries.
If PYTHONPATH is set correctly
If you successfully set your PYTHONPATH and the problem persists, try running the Python interpreter from the path you have gdata in.
cd path_which_has_subdirectory_gdata
python
In Python interpreter, try importing the gdata module:
import gdata
If that works, try also importing the module that causes the ImportError
:
import gdata.spreadsheet.service
If these imports work from Python interpreter, there's probably something wrong with your [script1]. If not, try to confirm that gdata module really is where you think it is; the correct directory for the module should contain a file named __init__.py
and PYTHONPATH should be set to point to the directory above the module in hierarchy.