0

I try to set autoreload to my development process, but it seems, that the method I learned from that thread is not working with my versions. I tried

  1. ipython -V: 0.10 and python -V Python 2.6.6
  2. ipython -V: 0.10.1 and python -V Python 2.7.3

but

%load_ext autoreload
%autoreload 2

returns

ERROR: Magic function `load_ext` not found.

which is kind of obvious, because

In [1]: %lsmagic
Available magic functions:
%Exit  %Pprint  %Quit  %alias  %autocall  %autoindent  %automagic  %bg  %bookmark  %cd          %clear  %color_info  %colors  %cpaste  %debug  %dhist  %dirs  %doctest_mode  %ed  %edit  %env      %exit  %hist  %history  %logoff  %logon  %logstart  %logstate  %logstop  %lsmagic  %macro  %magic  %p  %page  %paste  %pdb  %pdef  %pdoc  %pfile  %pinfo  %popd  %profile  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %quickref  %quit  %r  %rehash  %rehashx  %rep  %reset  %run  %runlog  %save  %sc  %store  %sx  %system_verbose  %time  %timeit  %unalias  %upgrade  %who  %who_ls  %whos  %xmode

this method is not available. How can I install other magic functions?

Community
  • 1
  • 1
Milla Well
  • 3,193
  • 3
  • 35
  • 50
  • You can't install new ipython? – Bula Nov 06 '12 at 12:15
  • which one should I install? my easy_install says `sudo easy_install ipython Searching for ipython Best match: ipython 0.10.1 ` – Milla Well Nov 06 '12 at 12:18
  • According to [this](http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython), `%autoreload` is in the [quarantine directory](http://ipython.org/ipython-doc/stable/whatsnew/version0.11.html#quarantine) of ipython 0.11, and fully available in version 0.12. – unutbu Nov 06 '12 at 12:21

1 Answers1

2

Current Install

In your current install, can you try:-

import ipy_autoreload

and see what you get?

New Install

Can you attempt to reinstall IPython with

pip install ipython

(for a local install if you are using virtualenv) or

sudo pip install ipython

if you are install your IPython system-wide.

And because pip install doesn't deal with sys path properly if you are on Mac OSX, you might need to do

easy_install -a readline   # `sudo easy_install -a readline` for system-wide install of course.

(if you are using Mac OSX)

If you have the latest IPython, you should see IPython 0.13.1 when you first load up the shell. And you shouldn't have any problems with %load_ext autoreload then.

Calvin Cheng
  • 35,640
  • 39
  • 116
  • 167
  • thanks, that worked fine! I also needed to correct my ipython shell script as described here: https://trac.macports.org/ticket/30702 . now I got IPython 0.13.1 running. Thanks a lot – Milla Well Nov 06 '12 at 12:31
  • Cool. I see you use `macports` too. Glad to be of service. I am a `macports` user myself and may I suggest that you use `macports` for non-python libraries but focus on using `pip` to directly install python-related libraries. It will save you a lot of headache. And `pypi` (which is where `pip` grabs the source code), will usually have more updated versions of a python library compared to `macports`. – Calvin Cheng Nov 06 '12 at 12:34
  • maybe I was to straightforward to change my startscript, It seems, that now, I can only import modules placed in the /opt/local/bin/ipython directory: `In [9]: ls` returns `a.py` but `In [10]: from a import * --------------------------------------------------------------------------- ImportError Traceback (most recent call last) /opt/local/bin/ipython in () ----> 1 from a import * ImportError: No module named a`. It looks like ipython has now some path issues – Milla Well Nov 06 '12 at 12:39
  • run in your `IPython` the following `import sys`; `sys.path` and paste the output in a pastebin. (pastebin.com) – Calvin Cheng Nov 06 '12 at 12:42
  • sys.path outputs a bunch of directories, but normally the directory I start ipython should be part of it? doesn't seem so. Same problem afterwards – Milla Well Nov 06 '12 at 12:46
  • Yes. The directory that you start your `ipython` should have part of `sys.path`. Here's mine as an example: http://dpaste.com/825687/ As you can see from the paste, `''` is in the list and therefore the current directory (which I start ipython shell from) is in the `PYTHONPATH`. – Calvin Cheng Nov 06 '12 at 12:48
  • `import sys; sys.path; sys.path.append("/Users/millawell/mydir") ` works. – Milla Well Nov 06 '12 at 12:48
  • Yes, if you have a custom directory which ipython isn't aware of (not in `PYTHONPATH`), you will need to specifically append it as you have done. – Calvin Cheng Nov 06 '12 at 12:49