Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPython startup customization

Tags:

ipython

I am trying to load things like from __future__ import division on the IPython startup on windows 7 64 bit machine, python 2.7 64 bit.

I searched the web and the recommended way I found is to put a .py file with instructions in: C:\Users\Me\.ipython\profile_default\startup. I've put a simple .py file containing

from __future__ import division
from __future__ import unicode_literals

in that folder. But it actually does nothing. What is more confusing is that the file seems to execute, because if I put some random error line in there, i see an error on Ipython start. Still division is not imported and have to re-import it typing from __future__ import division in the shell.

I tried it both on Anaconda and Winpython(settings for IPython on this distribution are in other folder) with the same result. After I re-import everything works fine. Totally stuck here, please help!

like image 494
flipper Avatar asked Jan 02 '14 09:01

flipper


1 Answers

Check to see if C:\Users\Me\.ipython\profile_default\ipython_config.py exists. If it doesn't, run

ipython profile create

from the command line to generate it. Next, open it in your favorite text editor and search for c.InteractiveShellApp.exec_lines. Uncomment that line (it's line 27 in my file) and edit it to be the following:

c.InteractiveShellApp.exec_lines = ["from __future__ import division", "from __future__ import unicode_literals"]

Save the file, restart IPython, and you should be all set.

like image 76
MattDMo Avatar answered Sep 30 '22 00:09

MattDMo