[IPython-User] Can't display image from external script

Arnaud Mounier arnaud.mounier@dijon.inra...
Fri Jan 24 03:25:52 CST 2014


Hi everyone,

first post so I introduce myself, I'm a data engineer in bio research 
lab in France. I want to setup notebooks for the researchers and I'm 
stuck with this problem : I didn't suceed to Image display in the 
notebook from an external python script (see bellow).

I follow this post
http://python.6.x6.nabble.com/IPython-User-ipython-notebook-how-to-display-image-not-from-pylab-td4497427.html

and my cell is this
IN %run test_display.py

Hello World ;).
True

Image ./data/img/yin-yang.png doesn't appear. The script is in the same 
path were notebook is launch and notebook is launch like this :

ipython notebook --pylab inline

The script "see" correctly the image but function Image don't succeed to 
display and don't genrate an error.

Any Idea where I do wrong ?

Thank's,

Arnaud.

the test script :
	

     #!/usr/bin/env python
     # -*- coding: utf-8 -*-

     import sys
     import getopt
     import os.path
     from IPython.core.display import Image

     class Usage(Exception):
         def __init__(self, msg):
             self.msg = msg

     def main(argv=None):
         if argv is None:
             argv = sys.argv
         try:
             try:
                 opts, args = getopt.getopt(argv[1:], "h", ["help"])
             except getopt.error, msg:
                  raise Usage(msg)
             # more code, unchanged
         except Usage, err:
             print >>sys.stderr, err.msg
             print >>sys.stderr, "for help use --help"
             return 2

         print "Hello World ;)."
         f_test = './data/img/yin-yang.png'
         print os.path.isfile(f_test)

         Image(filename=f_test)

     if __name__ == "__main__":
         sys.exit(main())

-- 
Arnaud Mounier
INRA - UMR Agroécologie 1347
CNRS - ERL IPM 6300 (Plant-Microorganism Interaction)
17, rue Sully - BP 86510 - F-21065 Dijon Cedex - France
Work phone : +33 380 693 167 - Fax : +33 380 693 753

https://www6.dijon.inra.fr/umragroecologie/Personnel/IPM/ITA/MOUNIER-Arnaud


More information about the IPython-User mailing list