About the new version of DeVIDE!

49 views
Skip to first unread message

honestapple

unread,
Feb 21, 2012, 6:43:31 AM2/21/12
to devide-users
Hello, I have tried the newest version of DeVIDE and I think it is a
useful tool for medical image analysis.
There are still some question about this version. I tried it on
Windows XP.
1. It seems that the easy_install package in the python does't work. I
tried to install the pymongo package following the help document and
easy_install just return with no information or errors.
2. It seems that Ecplise + pydev does't work. When I load python
console, It just load python2.7.2 console not the drepython, so I
should import itk and vtk. But when I use the python console under the
window menu in devide, the vtk and matplotlib have already been
loaded.
3. Can I update the itk in devide. I found that the itk you compiled
lack support to some data type. I have found an itk package with the
data type I need. Can I replace the itk package in devide with that
one and how to do that.

thank you.

Charl Botha

unread,
Feb 21, 2012, 8:11:41 AM2/21/12
to devide...@googlegroups.com
On Tue, Feb 21, 2012 at 12:43, honestapple
<honestappl...@gmail.com> wrote:
> 1. It seems that the easy_install package in the python does't work. I
> tried to install the pymongo package following the help document and
> easy_install just return with no information or errors.

You've found a bug, thank you! I've fixed this for future DeVIDE
releases with the following two patches:
http://code.google.com/p/devide/source/detail?r=710926cdd543e578d1fcf5fed4d814f2c3ebe967&repo=johannes
http://code.google.com/p/devide/source/detail?r=e3fd7102231fdcfae068ffc4d6eb92c5aed7eb21&repo=johannes
http://code.google.com/p/devide/source/detail?r=eee6eddb11e2815e95c55966fcc76e3421fcf841&repo=dre

You can fix your existing installation by editing DeVIDE-RE/dre.cfg
and making the following three changes:
1. change "python: %(dre_top)s\python\bin" to just "python:
%(dre_top)s\python" (i.e. remove the bin)
2. add these two lines to the bottom of your dre.cfg:
[env:pythonhome]
python: %(dre_top)s\python
3. download an updated dre.py from
http://dre.devide.googlecode.com/hg-history/eee6eddb11e2815e95c55966fcc76e3421fcf841/core/dre.py
and copy it OVER your existing dre.py in DeVIDE-RE

Now the following should work:
dre shell
pip install pymongo

Thank you for reporting this!

> 2. It seems that Ecplise + pydev does't work. When I load python
> console, It just load python2.7.2 console not the drepython, so I
> should import itk and vtk. But when I use the python console under the
> window menu in devide, the vtk and matplotlib have already been
> loaded.

You should follow the *exact* instructions as detailed here:
http://code.google.com/p/devide/wiki/HelpDRE -- it's normal that you
have to import itk and vtk to use that in your eclipse python code.

> 3. Can I update the itk in devide. I found that the itk you compiled
> lack support to some data type. I have found an itk package with the
> data type I need. Can I replace the itk package in devide with that
> one and how to do that.

If your ITK has also been built for python 2.7.x and with visual
studio, you could try overwriting the existing devide-re/itk
directory. Let us know if it works!

See you,
Charl

ning zhang

unread,
Feb 21, 2012, 8:44:12 PM2/21/12
to devide...@googlegroups.com
hello! I have tried the fix on the easy_install following what you had said. It didn't work!!!!.
 
dre shell
pip install pymongo
return with nothing.
import pymongo
return no such module
 
In addition, It seems that the devide didn't write information about python into registry, so when I install scipy manually, the installer complained that it can't find python in the registry.

2012/2/21 Charl Botha <c.p....@tudelft.nl>

--
You received this message because you are subscribed to the Google Groups "devide-users" group.
To post to this group, send email to devide...@googlegroups.com.
To unsubscribe from this group, send email to devide-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/devide-users?hl=en.


Charl Botha

unread,
Feb 22, 2012, 12:00:41 PM2/22/12
to devide...@googlegroups.com
On Wed, Feb 22, 2012 at 02:44, ning zhang
<honestappl...@gmail.com> wrote:
> dre shell
> pip install pymongo

These two commands should be typed in a command shell in the directory
in which you installed DeVIDE. The fact that "pip install pymongo" is
suspicious. Does "pip help" return anything?

> return with nothing.


> In addition, It seems that the devide didn't write information about python
> into registry, so when I install scipy manually, the installer complained
> that it can't find python in the registry.

That's deliberate. The DRE is completely self-contained and portable,
not really meant to be a system python. On Win64, adding SciPy to the
mix might complicate things, as the numpy bundled with DeVIDE is not
compatible, due primarily to compiler weirdness.

ning zhang

unread,
Feb 22, 2012, 8:57:45 PM2/22/12
to devide...@googlegroups.com
pip help also return nothing.
 
I have revised the dre.cfg file and overwrited the dre.py.
 
dre.cfg:

# DRE config written by johannes build system
# %(dre_top)s will be replaced by the DRE top-level directory.
[env:path]
python: %(dre_top)s\python
python_scripts: %(dre_top)s\python\Scripts
wxpython:
vtk: %(dre_top)s\VTK\bin
gdcm: %(dre_top)s\gdcm\bin
vtkdevide: %(dre_top)s\vtkdevide\lib
vtktudoss: %(dre_top)s\vtktudoss\lib
itk:%(dre_top)s\Insight\bin;%(dre_top)s\wrapitk\lib\InsightToolkit\WrapITK\lib
[env:pythonpath]
devide: %(dre_top)s\devide
vtk: %(dre_top)s\VTK\lib\site-packages;%(dre_top)s\VTK\bin
gdcm: %(dre_top)s\gdcm\lib;%(dre_top)s\gdcm\bin
vtkdevide: %(dre_top)s\vtkdevide\lib;%(dre_top)s\vtkdevide\lib
vtktudoss:%(dre_top)s\vtktudoss\lib;%(dre_top)s\vtktudoss\lib
itk:%(dre_top)s\wrapitk\lib\InsightToolkit\WrapITK\Python;%(dre_top)s\wrapitk\lib\InsightToolkit\WrapITK\lib
[env:pythonhome]
python: %(dre_top)s\python

dre.py:
 
# Copyright (c) Charl P. Botha, TU Delft.
# All rights reserved.
# See COPYRIGHT for details.
# main DRE driver script
import ConfigParser
import copy
import os
import subprocess
import sys
help_msg = """Welcome to the DRE (DeVIDE Runtime Environment) runner.
With this programme, you can invoke DREAMs, or DRE Application
Modules, for example DeVIDE or IPython with VTK, ITK, etc.
Invoke as follows:
    dre dream_name [param1 param2 param3]
Where dream_name can be:
1. One of the built-in dreams:
    devide   - Graphical medical visualisation application application builder.
    help     - Show this message.
    python   - Python interpreter with VTK, ITK, wxPython available.
2. The full path to an arbitrary Python script.
3. A Python package or script located in dre-toplevel/dreams/
    versions  - Output versions of included libraries.
    ipython   - Interactive Python shell (no graphics)
    pythonwx  - Simple graphical Python shell with tooltips, history, etc.
    ipythonwx - Less simple graphical version of IPython.
    shell     - Start a system shell with DRE-determined environment.
"""
class DRE:
    def disp_usage(self):
        print help_msg
    def helper_run_python(self, args):
        """Helper function used by built-in dreams to execute the DRE-enabled python on stuff.
        @param args: Will be passed to python as command line argumenst.
        """
        p = subprocess.Popen([self.python_bin] + args, env=self.env)
        # wait for the process to return
        p.communicate()
    def helper_args_preprocess(self):
        if len(sys.argv) > 2:
            args = sys.argv[2:]
        else:
            args = []
        return args

    def run_devide(self):
        """Built-in dream to run the DeVIDE that is packaged with the DRE.
        """
        devide_fn = os.path.join(self.dre_top, 'devide', 'devide.py')
        # if any MORE arguments were passed after "devide", pass that on
        args = self.helper_args_preprocess()
        self.helper_run_python([devide_fn] + args)
    def run_drepython(self):
        """Run the DRE Python with the environment correctly setup so that
        all DRE libraries can be imported.
        """
        # if any MORE arguments were passed after "python", pass that on
        # to the python interpreter
        args = self.helper_args_preprocess()
        self.helper_run_python(args)
    def run_help(self):
        print help_msg
    def run_pyfile(self, pyfilename):
        args = self.helper_args_preprocess()
        self.helper_run_python([pyfilename] + args)
    def main(self):
        # first check for builtin
        # then check for dream in dre_top/dreams/
        # then check for file / dir
        # simple argument checking no getopt: only sys.argv[1] is checked,
        # all subsequent arguments are passed to the called script.
        if len(sys.argv) < 2:
            self.disp_usage()
            return
        # now setup some variables we'll need ############################
        self.builtin_dreams = {
                'python' : self.run_drepython,
                'devide' : self.run_devide,
                'help'   : self.run_help}
        # first determine the directory containing dre.py
        self.dre_top = os.path.abspath(os.path.dirname(sys.argv[0]))
        self.dreams_dir = os.path.join(self.dre_top, 'dreams')
        if os.name == 'nt':
            self.python_bin = os.path.join(self.dre_top, 'python', 'python.exe')
        elif os.name == 'posix':
            self.python_bin = os.path.join(self.dre_top, 'python', 'bin', 'python')
        else:
            # if nothing else works, we use the python that's executing this script
            # should be the right one in most cases
            self.python_bin = sys.executable
        # read the DRE configuration file
        cp = ConfigParser.ConfigParser({'dre_top' : self.dre_top})
        cf = open(os.path.join(self.dre_top, 'dre.cfg'),'r')
        cp.readfp(cf)
       
        # get the specified environment from dre.cfg and merge it with the
        # existing environment.
        #####################################################################
       
        # first make a deepcopy of the existing environment
        self.env = copy.deepcopy(os.environ)
        # delete PYTHONPATH, else it could lead to system libraries taking
        # preference over our own see:
        # http://code.google.com/p/devide/issues/detail?id=188
        if self.env.has_key('PYTHONPATH'):
            del self.env['PYTHONPATH']
       
        # now merge all sections from dre.cfg with our copy of the environment
        for sec in cp.sections():
            if sec.startswith('env:'):
                env_var = sec[4:].upper()
                # love the python:
                # get all values from this section of the config file
                # append them altogether with either ; or : in between,
                # depending on OS
                elems = os.pathsep.join([i[1] for i in cp.items(sec) if i[0] != 'dre_top'])
                # if this env variable already exists, prepend to it:
                v = self.env.get(env_var)
                if v is not None:
                    elems = os.pathsep.join([elems, v])
                self.env[env_var] = elems
        # we also insert the DRE_TOP variable in the environment, this
        # points to the top-level DRE dir containing the dre.py file.
        self.env['DRE_TOP'] = self.dre_top

        # start command-line processing ###############################
        dream_name = sys.argv[1]
        candidate_dreams_path = os.path.join(
                self.dreams_dir, '%s.py' % (dream_name,))

        # check for builtin
        m = self.builtin_dreams.get(dream_name)
        if m is not None:
            m()
        elif os.path.exists(dream_name):
            self.run_pyfile(dream_name)
        elif os.path.exists(candidate_dreams_path):
            self.run_pyfile(candidate_dreams_path)

        else:
            print "Could not find specified DREAM."

if __name__ == "__main__":
    DRE().main()

I install the DeVIDE in the D:\Program Files\DeVIDE-RE.
I run the two command in this directory and they return nothing, the same as "pip help"
 
I have registerd python in DRE through edit registry in Windows. The scipy could be installed successfully. I wondered whether the easy_install or pip could be reinstalled again.
 
2012/2/23 Charl Botha <c.p....@tudelft.nl>

ning zhang

unread,
Feb 22, 2012, 9:10:04 PM2/22/12
to devide...@googlegroups.com
I failed to install setuptools manually. When I run easy_install, it return error message: No module named pkg_resources.

2012/2/23 ning zhang <honestappl...@gmail.com>

Charl Botha

unread,
Feb 23, 2012, 3:10:38 AM2/23/12
to devide...@googlegroups.com
On Thu, Feb 23, 2012 at 03:10, ning zhang
<honestappl...@gmail.com> wrote:
> I failed to install setuptools manually. When I run easy_install, it return
> error message: No module named pkg_resources.

That's exactly the error you should get without the dre.cfg and dre.py
modifications above, and without running dre shell first. I tested
just yesterday, and could run pip without problems.

I'll test on different windows images and let you know. Please keep me
up to date on any progress that you might be making.

Thanks,
Charl

Reply all
Reply to author
Forward
0 new messages