Abstract
Python IPython greatly improves the usability of the interactive shell, but The disadvantage is that it ignores the environment variable PYTHONSTARTUP.
In this entry, like a normal Python interactive shell, I will show you how to load the .py file specified when IPython starts.
The operation has been confirmed in Debian. Maybe you can set it up the same way on Linux, If you have any mistakes, please contact me m (_ _) m
There are two main steps.
Run the following command in the terminal:
ipython profile create
Then, the default profile was created as shown below, and The location where you want to save the default profile is displayed in the terminal. (The {directory name} part depends on the environment.)
[ProfileCreate] Generating default config file: u'{Directory name}/ipython_config.py'
Open the default profile you just created in a suitable editor and Look for the next line.
ipython_config.py
# List of files to run at IPython startup.
# c.InteractiveShellApp.exec_files = []
First, uncomment c.InteractiveShellApp.exec_files = []
.
Then specify in the list the .py file you want to load when IPython starts.
For example, if you want to load /home/my_name/bin/python_startup.py
:
ipython_config.py
# List of files to run at IPython startup.
c.InteractiveShellApp.exec_files = ["/home/my_name/bin/python_startup.py"]
The file specified above will be loaded when IPython starts.
Recommended Posts