For ipython, there are two ways to achieve this. Both involve ipython's configuration directory which is located in ~/.ipython
.
- Create a custom ipython profile.
- Or you can add a startup file to
~/.ipython/profile_default/startup/
For simplicity, I'd use option 2. All you have to do is place a .py
or .ipy
file in the ~/.ipython/profile_default/startup
directory and it will automatically be executed. So you could simple place import numpy as np
in a simple file and you'll have np in the namespace of your ipython prompt.
Option 2 will actually work with a custom profile, but using a custom profile will allow you to change the startup requirements and other configuration based on a particular case. However, if you'd always like np
to be available to you then by all means put it in the startup directory.
For more information on ipython configuration. The docs have a much more complete explanation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…