I've added a .pythonrc.py script to my home directory with the commands below:
import os
import sys
print 'Welcome'
I've confirmed that it is actually executable by running python .pythonrc.py
and by loading the python interpreter and running execfile('.pythonrc.py')
. However, when I start interactive mode, it seems that the script is never being loaded. Calls to methods in os or sys return errors that os or sys are not defined. Has anyone seen this before? Any suggestions?
I'm running Python 2.6 on an Ubuntu 10 server.
Thanks!
You should set the Environment variable PYTHONSTARTUP to point to the start up script that you created.
In Ubuntu you can edit the ~/.bashrc file and add this line in the end:
export PYTHONSTARTUP=~/.pythonrc.py
Now you should start a new shell and run python.
Hope it helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With