DEV Community

Cover image for Ipython-Config
Waylon Walker
Waylon Walker

Posted on • Originally published at waylonwalker.com

Ipython-Config

I use my ipython terminal daily. It's my go-to way of running python most of
the time. After you use it for a little bit you will probably want to set up a
bit of your own configuration.

install ipython

Activate your virtual environment of choice and pip install it. Any time you are running your project in a virtual environment, you will need to install ipython inside it to access those packages from ipython.

pip install ipython
Enter fullscreen mode Exit fullscreen mode

You are using a virtual environment right? Virtual environments like venv or conda can save you a ton of pain down the road.

profile_default

When you install ipython you start out with no config at all. Running ipython profile create will start a new profile called profile_default that contains all of the default configuration.

ipython profile create
Enter fullscreen mode Exit fullscreen mode

This command will create a directory ~/.ipython/profile_default

multiple configurations

You can run multiple configurations by naming them with ipython profile create [profile_name] This command will create a directory ~/.ipython/[profile_name]

ipython profile create my_profile
ipython --profile=my-profile
Enter fullscreen mode Exit fullscreen mode

startup

Inside the profile, there will be a startup directory ~/.ipython/profile_default/startup. Ipython will execute each of the files in this directory on startup. This is particularly handy to create custom prompts, search, or import packages automatically for certain profiles.


article cover

Custom Ipython Prompt

I've grown tired of the standard ipython prompt as it doesn't do much to give me any useful information. The default on

read more waylonwalker.com

This post creates a custom ipython prompt by creating a ~/.ipython/profile_default/startup/prompt.py file.

ipython_config.py

There are tons of options that are in the ipython_config.py file. My favorite is to automatically enable my favorite magic command autoreload.


article cover

Autoreload in Ipython

Autoreload in python

read more waylonwalker.com

c.InteractiveShellApp.extensions = ['autoreload'
c.InteractiveShellApp.exec_lines = []'%autoreload 2']
c.InteractiveShellApp.exec_lines.append('print("Warning: disable autoreload in ipython_config.py to improve performance.")')
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

Collapse
 
mccurcio profile image
Matt Curcio

Hi Waylon,
As a Data Eng., how often do you use R?

Collapse
 
waylonwalker profile image
Waylon Walker

I have never used it. I have written a bit of R, but never used it for any real project. I have nothing against R, python is what I and my team know well I don't think there would be any benefit in using R for us. Over the past year my focus went into automation and deployment, I have probably wrote just as much bash as I have python.

Collapse
 
mccurcio profile image
Matt Curcio

Very interesting,
Another question, Do you make a lot of 'dashboards'? If so, what libraries do you prefer?

Thread Thread
 
waylonwalker profile image
Waylon Walker

I don't make a ton of dashboards. I actually made my own that mapped the pandas plot API to create c3.js plots, it made it simple to create a json API and control state with react.

I would probably take another look at streamlit/dash for quickly creating prototype dashboards.