How to Copy from IPython session without terminal prompts

You can use the %history magic to extract the interesting parts from your session. They will be shown in terminal without any of the junk. Example In [1]: import numpy as np In [2]: a = np.random(10) ————————————————————————— TypeError Traceback (most recent call last) <ipython-input-2-83ce219ad17b> in <module>() —-> 1 a = np.random(10) TypeError: ‘module’ object … Read more

What is %pylab?

%pylab is a magic function in ipython. Magic functions in ipython always begin with the percent sign (%) followed without any spaces by a small text string; in essence, ipython magic functions define shortcuts particularly useful for interactive work, e.g., to give you an idea of how magic functions work in python, a few of … Read more

Running an IPython/Jupyter notebook non-interactively

Yes it is possible, and easy, it will (mostly) be in IPython core for 2.0, I would suggest looking at those examples for now. [edit] $ jupyter nbconvert –to notebook –execute original.ipynb –output=new.ipynb It is now in Jupyter NbConvert. NbConvert comes with a bunch of Preprocessors that are disabled by default, two of them (ClearOutputPreprocessor … Read more

How do I set up Jupyter/IPython Notebook for Django?

Install django-extensions from https://github.com/django-extensions/django-extensions/blob/master/docs/index.rst pip install django-extensions Change your settings file to include ‘django-extensions’ INSTALLED_APPS += [‘django_extensions’] Run your Django server like this: python manage.py shell_plus –notebook alter to suit, and run this in your first cell import os, sys PWD = os.getenv(‘PWD’) os.chdir(PWD) sys.path.insert(0, os.getenv(‘PWD’)) os.environ.setdefault(“DJANGO_SETTINGS_MODULE”, “local_settings.py”) import django django.setup() Now you should be … Read more

IPython and Jupyter autocomplete not working

A possible reason a user may believe that autocomplete is not working may be that autocomplete is just taking too long. Circa 2020-11-27 this is particularly true for Pandas when operating with jedi in a Jupiter notebook environment. The issue can be solved by using the following magic which deactivates jedi %config Completer.use_jedi = False … Read more

Installing a pip package from within a Jupyter Notebook not working

In IPython (jupyter) 7.3 and later, there is a magic %pip and %conda command that will install into the current kernel (rather than into the instance of Python that launched the notebook). %pip install geocoder In earlier versions, you need to use sys to fix the problem like in the answer by FlyingZebra1 import sys … Read more