===== Python Installation and Test Notes (Win32, XP) ===== ==== Install Python. ==== * python-2.6.5.msi downloaded from * http://www.python.org/download/releases/2.6.5/ by default, installed under C:\Python26 Then installing site-packages. ==== Install Numpy and Scipy ==== * numpy-1.5.0b1-win32-superpack-python2.6.exe * scipy-0.8.0-win32-superpack-python2.6.exe Both downloaded from the link in * http://www.scipy.org/Download Just clicking and executing. ==== Install matpotlib. ==== matplotlib-1.0.0.win32-py2.6.exe downloaded from link in http://matplotlib.sourceforge.net/ ==== Install IPython ==== downloaded * ipython-0.10.win32-setup.exe from * http://ipython.scipy.org/doc/rel-0.10/html/install/install.html and click to install. check from IDLE: IDLE 2.6.5 >>> import IPython >>> print IPython.__version__ 0.10 >>> From the program menue, select IPython -> Pylab starts up a command line tool that shows ********************************************************************** Welcome to IPython. I will try to create a personal configuration directory where you can customize many aspects of IPython's functionality in: C:\Documents and Settings\Miura\_ipython Initializing from configuration: C:\Python26\Lib\site-packages\IPython\UserConfi g Successful installation! Please read the sections 'Initial Configuration' and 'Quick Tips' in the IPython manual (there are both HTML and PDF versions supplied with the distribution) to make sure that your system environment is properly configured to take advantage of IPython's features. Important note: the configuration system has changed! The old system is still in place, but its setting may be partly overridden by the settings in "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file if some of the new settings bother you. Please press to start IPython. ==== Set up environmental variables in Win ==== - new environmental variable "PYTHONPATH" and C:\Python26;C:\Python26\Lib;C:\Python26\Lib\site-packages - add follwoing path to PATH (for commandine) C:\Python26 Test with the following code: >>> import numpy, scipy >>> numpy.test() ... then get **errors**: Running unit tests for numpy Traceback (most recent call last): File "", line 1, in numpy.test() File "C:\Python26\Lib\site-packages\numpy\testing\nosetester.py", line 321, in test self._show_system_info() File "C:\Python26\Lib\site-packages\numpy\testing\nosetester.py", line 187, in _show_system_info nose = import_nose() File "C:\Python26\Lib\site-packages\numpy\testing\nosetester.py", line 69, in import_nose raise ImportError(msg) ImportError: Need nose >= 0.10.0 for tests - see http://somethingaboutorange.com/mrl/projects/nose [[http://somethingaboutorange.com/mrl/projects/nose/0.11.2/|seems that I need to install another module called nose]] so download the file, unzip. From DOS prompt go into the folder \nose-0.11.2. Then >C:\temp\nose-0.11.2>python setup.py install according to * http://answerpot.com/showthread.php?708617-%231550:+Memmap+test+failure I get the following test failure on all msvc9 builds of numpy 1.5.0.dev for Windows. A patch is attached. {{{ ERROR: test_filename (test_memmap.TestMemmap) ---------------------------------------------------------------------- Traceback (most recent call last): File "X:\Python26-x64\lib\site- packages\numpy\core\tests\test_memmap.py", line 60, in test_filename os.unlink(tmpname) WindowsError: [Error 32] The process cannot access the file because it is being used by another process: }}} This seems to be already reported. #1550: Memmap test failure ----------------------+----------------------------------------------------- Reporter: cgohlke | Owner: somebody Type: defect | Status: closed Priority: normal | Milestone: 1.5.0 Component: Other | Version: devel Resolution: fixed | Keywords: ----------------------+----------------------------------------------------- Changes (by rgommers): * status: new => closed * resolution: => fixed Comment: Thanks, applied in r8606, r8607. for this error, some people say its not really problem: * http://projects.scipy.org/numpy/ticket/1574 ... so maybe ignore for now and wait for the new release to include the fix above. ==== Test wiith matplotlib ==== http://matplotlib.sourceforge.net/ from DOS command prompt from pylab import * plot([1,2,3]) show() this does work. Shows a new window with plot. ==== Using Pydev in Eclipse (helios) ==== Install Pydev * http://pydev.org/manual_101_interpreter.html * Install using Help -> Install new software. === Settings === set path to the python interpreter in C:\Python26. Then make a new project, and inside create a new python module. using the same code as above, run the script ---> this does work as well. Shows a new window with plot. === Testing Command line interface (console) in Python === In the bottom console, select “Pydev console” from “Open Console” icon. This will start up interactive python interpreter. ==== Accessing ImageJ as Image Processing Library==== Jython interpreter must be used instead of Python interpreter for accessing Java. For this, pydev installed in eclipse do the job. This is quite useful but the drawback is that one cannot use numpy and scipy. Instead, one should use java numerical libraries as recommended by Albert Cardona. * [[http://math.nist.gov/javanumerics/jama/|JaMa]] (Java Matrix Package) * [[https://java3d.dev.java.net/|Java3D]] * see also [[http://math.nist.gov/javanumerics/#libraries|a list of libraries]] - Basic setting: In eclipse, [Window > Preference], collapse Pydev-Interpreter-Jython tee. If you see nothing listed in "Jython interpreter" field, then you need to set path to a jython interpreter. If you do not have one, you could download the latest from Jython project page (http://www.jython.org/). In my case, I pointed the reference to jython.jar within FIJI jar folder. Since FIJI has automatic updating function, this jar should be the latest one (Python2.5 comparable). - Make a new pydev project by [File > New > Pydev project], Fill "Project name", choose project type as Jython, and Grammer version 2.5, choose jython (this name is what you gave when you set the library path in 1.) from Interpreter drop down menu. - Right click the newly created project folder and [new > pydev module]. In the creation panel, choose whatever the project name (could also be blank), fill Name of the module ("testjy" in this example) and Finish. - Right click the newly created project folder again, and select "prpoperties". Select Pydev-PYTHONPATH, select "external libraries" tab, and "Add zip/jar/egg" to set ij.jar as an external library. - optional: to access lugins in ImageJ plugin folder, add that plugin class file or jar file in the library path as well. Double clicking test.py will open the file in the editor window. COpy and paste the following: from ij import IJ import ij.process.ImageProcessor as IP blobs = IJ.openImage("http://rsb.info.nih.gov/ij/images/blobs.gif") imp = blobs.createImagePlus() ip = blobs.getProcessor().duplicate() imp.setProcessor("blobs copy", ip) imp.show() ip.setThreshold(147, 147, IP.NO_LUT_UPDATE) IJ.run(imp, "Convert to Mask", "") IJ.run(imp, "Watershed", "") save the file, right click the file in Pydeve Package view and select [Run as > Jython Run]. If segmented blob appears, then the setup is working. To dynamically access jython-ij, set external library path in [window > preferences] interpreter-Jyton pane. Adding ij.jar in the library path will enable you to access jython just like in IDLE by clicking open console icon and selecting pydev console.