Installing pythonstartup file

installation, python, unix, windows-7

Solution

In your `~/.bashrc`:

export PYTHONSTARTUP=$HOME/.pythonstartup

and put your python code in `$HOME/.pythonstartup`, like:

import rlcompleter
import readline

readline.parse_and_bind("tab: complete")

Then run the interactive shell:

python

See the imports from PYTHONSTARTUP are processed. This only works in python interactive mode.

For more information about `PYTHONSTARTUP` variable, read the python man page:

$ man python

Problem

How do I install the `pythonstartup` file so that it runs on command like `python myfile.py`? I tried to install it into my `/home/myuser` directory for Ubuntu, but it said that I had insufficient permissions. Furthermore, different places say alternately that it should be in all caps or in all lower case with a period before it. The Python command line guide does not seem to explain where to put the file, or how to change which environment variable to 'point' to it.

Original source