0% found this document useful (0 votes)
99 views

VTK - PythonDevelopment - KitwarePublic

This document provides instructions for setting up an Eclipse development environment with Pydev for developing Python scripts using VTK on Windows, Linux, and MacOS. It describes setting environment variables to include VTK paths and how to configure an Eclipse Pydev project to integrate with VTK. Key steps include setting environment variables for the operating system, installing Pydev in Eclipse, and modifying the Pydev project's PYTHONPATH to include VTK folder paths for code completion and debugging of Python scripts.

Uploaded by

kinny1974
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views

VTK - PythonDevelopment - KitwarePublic

This document provides instructions for setting up an Eclipse development environment with Pydev for developing Python scripts using VTK on Windows, Linux, and MacOS. It describes setting environment variables to include VTK paths and how to configure an Eclipse Pydev project to integrate with VTK. Key steps include setting environment variables for the operating system, installing Pydev in Eclipse, and modifying the Pydev project's PYTHONPATH to include VTK folder paths for code completion and debugging of Python scripts.

Uploaded by

kinny1974
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

13/06/12

VTK/PythonDevelopment - KitwarePublic

VTK/PythonDevelopment
From KitwarePublic
< VTK

Contents
1 VTK Eclipse/Pydev 2 Environment variables for Linux/MacOS 3 Environment variables for Windows 4 Setting up Eclipse and Pydev 4.1 Additional steps for Linux 5 Installing Pydev 6 Pydev project configuration

VTK Eclipse/Pydev
Eclipse with Pydev provides a good development environment for developing Python scripts for VTK. You get Syntax checking/highlighting and code completion and debugging. However in order to integrate VTK we need to do a few extra steps. This article will tell you you how to set up the development environment for Windows, Linux and MacOSX. The folowing discussion assumes that the environment variables have been set and that the user is familiar with or willing to learn the Eclipse IDE.

Environment variables for Linux/MacOS


The environment variables are assuming the following directory structure, so you may need to change paths in the environment variables to suit your own directory structure. %KITWARE_PATH%\build\VTK %KITWARE_PATH%\src\VTK %KITWARE_PATH%\src\VTKData %KITWARE_PATH%\src\VTKLargeData Note: You must set KITWARE_PATH to the root path of your VTK build, for example '/home/username/Code/Kitware'. Edit ~ . a h cand add in the following lines. /bsr
www.vtk.org/Wiki/VTK/PythonDevelopment 1/4

13/06/12

VTK/PythonDevelopment - KitwarePublic

#iwr Ktae epr KTAEPT=hm/sraeCd/iwr xot IWR_AH/oeuenm/oeKtae #VK T epr VKDT_OT$IWR_AHscVKaa xot T_AARO=KTAEPT/r/TDt epr VKLREDT_OT$IWR_AHscVKagDt xot T_AG_AARO=KTAEPT/r/TLreaa epr VKRO=KTAEPT/r/T xot T_OT$IWR_AHscVK # epr VKDR$IWR_AHbidVK xot T_I=KTAEPT/ul/T #FrVKTLporm. o T C rgas epr TLIPT=$T_I/rpigTl xot CLBAH'VKDRWapn/c' aisvk'VKDRbnvk la t=$T_I/i/t' #FrVKPto porm. o T yhn rgas aisvkyhn'VKDRbnvkyhn la tpto=$T_I/i/tpto' epr PTOPT=PTOPT:VKDRWapn/yhn$T_I/i xot YHNAH$YHNAH$T_I/rpigPto:VKDRlb

Then do:
suc ~.ahc ore /bsr

Environment variables for Windows


The environment variables are assuming the following directory structure, so you may need to change paths in the environment variables to suit your own directory structure. %KITWARE_PATH%\build\VTK\Release %KITWARE_PATH%\build\VTK\Debug %KITWARE_PATH%\src\VTK %KITWARE_PATH%\src\VTKData %KITWARE_PATH%\src\VTKLargeData Set the following environment variables: KITWARE_PATH VTK_BIN This will be the root path e.g C:\Kitware or C:\Users\<your username>\Code\Kitware you can choose whatever you prefer here %KITWARE_PATH%\build\VTK\Release\bin

VTK_DATA_ROOT %KITWARE_PATH%\src\VTKData VTK_LARGE_DATA_ROOT %KITWARE_PATH%\src\VTKLargeData VTK_ROOT PYTHONPATH TCLLIBPATH %KITWARE_PATH%\src\VTK %KITWARE_PATH%\build\VTK\Release\Wrapping\Python <root_path>/build/VTK/Release/Wrapping/Tcl/Release

Note that for TCLLIBPATH the path must be fully expanded and \ replaced by /. Replace <root_path> with whatever you used for KITWARE_PATH replacing \ with / e.g C:/Kitware. You will need to add the following path to the PATH environment variable:
www.vtk.org/Wiki/VTK/PythonDevelopment 2/4

13/06/12

VTK/PythonDevelopment - KitwarePublic

%IWR_AH\ul\T\ees\i\ees KTAEPT%bidVKRlaebnRlae

In Windows these are set by going to Control Panel|All Control Panel Items|System and selecting "Advanced System Settings". Then select the Advanced tab and click on Environment Variables.

Setting up Eclipse and Pydev


You must have Java installed, either JRE or JDK, download and install from http://www.java.com. Download Eclipse Classic from http://www.eclipse.org/downloads/ Unzip it and place the eclipse folder in a suitable place. Additional steps for Linux Go to the eclipse folder. Check eclipse.ini and make sure that, if you have manually installed Java, the openfile section looks something like this:
oefl pnie -m v /s/oa/d/d1700/i/aa urlcljkjk.._3bnjv

Of course replace / s / o a / d / d 1 7 0 0 / i / a awith the path to the java version you installed. urlcljkjk.._3bnjv Create a script, called eclipse.sh, with the following content:
#/i/ah !bnbs #Satelpewt sm evrnetvralsst tr cis ih oe niomn aibe e. epr KTAEPT=hm/sraeCd/iwr xot IWR_AH/oeuenm/oeKtae epr VKTXBO_AA$IWR_AHscVKetokDt xot T_ETOKDT=KTAEPT/r/TTxbo/aa epr VKDT_OT$IWR_AHscVKaa xot T_AARO=KTAEPT/r/TDt epr VKLREDT_OT$IWR_AHscVKagDt xot T_AG_AARO=KTAEPT/r/TLreaa <aht_cis>elpe pt_oelpe/cis

Remember to change KITWARE_PATH to the root path of your VTK build, for example '/home/username/Code/Kitware' and to change <path_to_eclipse> to the path to the path to the eclipse folder. Both these paths must be absolute paths. Save and mark this as executable. The purppose of this script is to set the VTK environment variables so that we can run the Python scripts within Pydev. Now create a file called eclipse.desktop with this content:
www.vtk.org/Wiki/VTK/PythonDevelopment 3/4

13/06/12

VTK/PythonDevelopment - KitwarePublic

[eko Ety Dstp nr] Tp=plcto yeApiain Ecdn=TnoigUF8 Nm=cis aeElpe CmetTeElpeDvlpetEvrnet omn=h cis eeomn niomn Ee=pt_oelpe/cis.h xc<aht_cis>elpes Io=pt_oelpe/cnxm cn<aht_cis>io.p Tria=as emnlfle

Once again, change <path_to_eclipse> to point to your eclipse directory, then save the file. It will appear as a file called Eclipse and will have the eclipse logo. Now right-click on the file and mark it as executable. Thw purpose of this is to enable the user to just click on Eclipse and everything will be set up for VTK. From now on, to run eclipse, click on this file called Eclipse. You can copy and paste it anywhere you like because the paths are absolute. For example you might place it on your desktop.

Installing Pydev
Then start eclipse and install Pydev, see: http://www.pydev.org/ for instructions on how to do this.

Pydev project configuration


Once the previous steps have been completed you can start eclipse and create a Pydev project. The environment variables will have been set automatically in Windows and, if you are using Linux, they should be set automatically be executing either eclipse.sh or Eclipse in the eclipse folder. After you create your Pydev project you will need to edit PYTHONPATH to include the paths to VTK. To do this right-click on the project, select "Properties" then click on the "External Libraries" tab and add the full paths to the following folders in your build directory: VTK/Wrapping/Python VTK/lib VTK/bin Once this is done you will be able to edit and run any python script in your project. Retrieved from "http://www.vtk.org/Wiki/VTK/PythonDevelopment" This page was last modified on 17 April 2012, at 23:25. Content is available under Attribution2.5.

www.vtk.org/Wiki/VTK/PythonDevelopment

4/4

You might also like