How to specify a .py file to load at startup in IPython 0.13

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.

  1. Create a default profile for IPython
  2. Edit the default profile

1. Create a default profile for IPython

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'

2. Edit default profile

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

How to specify a .py file to load at startup in IPython 0.13
How to create a JSON file in Python
How to read a file in a different directory
How to specify a .ui file in the dialog / widget GUI in PySide
How to specify a schema in Django's database settings
How to turn a .py file into an .exe file
How to run a Python file at a Windows 10 command prompt
How to import NoteBook as a module in Jupyter (IPython)
A story about how to specify a relative path in python.
How to import a file anywhere you like in Python
A note on how to load a virtual environment in PyCharm
How to import NoteBook as a module in Jupyter (IPython)
How to create a config file
How to get a stacktrace in python
Setting to change IPython prompt to'>>>' at startup
How to specify non-check target in Flake8
How to revive cells in iPython notebook
[LPIC 101] How to specify the disk partition number in the GRUB configuration file
How to put a line number at the beginning of a CSV file
How to read a CSV file with Python 2/3
How to clear tuples in a list (Python)
How to hold a competition at Coda Lab
How to embed a variable in a python string
How to implement a gradient picker in Houdini
How to specify TLS version in python requests
How to notify a Discord channel in Python
[Python] How to draw a histogram in Matplotlib
How to create a Rest Api in Django
How to write a named tuple document in 2020
How to count numbers in a specific range
How to Mock a Public function in Pytest
How to drop Google Docs in one folder in a .txt file with python
How to read a serial number file in a loop, process it, and graph it
Parse a JSON string written to a file in Python
How to convert / restore a string with [] in python
How to display the modification date of a file in C language up to nanoseconds
[Python] How to expand variables in a character string
A memorandum on how to use keras.preprocessing.image in Keras
How to load files in Google Drive with Google Colaboratory
A memorandum to run a python script in a bat file
How to use IPython
How to use template engine in pyramid 1 file application
How to display DataFrame as a table in Markdown
How to convert a mel spectrogram back to a wav file
[Work efficiency] How to change file names in Python
How to execute a command using subprocess in Python
Output a binary dump in binary and revert to a binary file
How to reference static files in a Django project
[Linux] How to put your IP in a variable
How to slice a block multiple array from a multiple array in Python
How to output a document in pdf format with Sphinx
How to shuffle a part of a Python list (at random.shuffle)
How to use the __call__ method in a Python class
Change the standard output destination to a file in Python
How to check ORM behavior in one file with django
How to specify a public directory Python simple HTTP server
How to temporarily implement a progress bar in a scripting language
How to define multiple variables in a python for statement
I tried "How to get a method decorated in Python"
How to develop in a virtual environment of Python [Memo]
How to specify Cache-Control for blob storage in Azure Storage in Python