wiki:IDEforOT

Version 15 (modified by michael.baudin@…, 7 years ago) (diff)

--

How to setup a Integrated Development Environment for OpenTURNS

Abstract

In this page, we describe how to install and configure a development environment for OpenTURNS. More precisely, we present a method to install an configure the Spyder interactive development environment for the Python language on Windows and on Linux.

Installing OT+Spyder on Windows

Install the Windows version of OpenTURNS

http://sourceforge.net/projects/openturns/files/openturns/

More precisely, we can install:

  • openturns-setup-1.0.exe
  • openturns-developers-setup-X.X.exe

We now make the assumption that OpenTURNS was installed in the

C:\OpenTURNS

directory.

Install Pythonxy for Windows

http://code.google.com/p/pythonxy/wiki/Downloads

It should be noticed that the installed version of Pythonxy must be consistent with the Python interpreter used by OpenTURNS.

For example, for OpenTURNS 1.0, this is Python 2.6. Therefore, we can install the binary "Python(x,y)-2.6.6.2.exe" from :

http://ftp.ntua.gr/pub/devel/pythonxy/

Run Spyder from a script

Perhaps the simplest method is to run Spyder from the following script:

SpyderForOpenTURNS-1.0.bat

This script defines the environment variables that Spyder needs to know where OpenTURNS is installed. To use this script, we simply click on it: this launches Spyder with a pre-configured OpenTURNS-aware environment.

Check the installation

Now that Spyder is launched, we can just import the openturns module, as shown in the following figure.

A screenshot of the OpenTURNS module in Spyder

Manage the environment "by hand"

It is also possible to manage the environment by defining the appropriate environment variables.

Let Spyder know OpenTURNS

To do this, we just have to define the PYTHONPATH environment variable, so that it contains the directory where OpenTURNS is installed.

This can be done by different ways:

  • defining the variable from the Windows configuration dialog,
  • by using the Spyder PYTHONPATH dialog box.

Since the Spyder PYTHONPATH dialog box is simpler, we present this method.

In Spyder, go to the "Tools > Management of PYTHONPATH" dialog box.

The Tools > Manage PYTHONPATH menu entry.

Then push the "+ Add a directory" button and add the directory:

C:\OpenTURNS\lib\python26\site-packages

as in the following figure.

The Spyder PYTHONPATH dialog.

Update the PATH environment variable

This makes so that the dll from OpenTURNS can be known.

This can be done by two different ways:

  • update the PATH environment variable in the Environment Variables Windows dialog box,
  • update the PATH environment variable from a .bat script and run Spyder from there.

Let us present how to update the environment variable from the Environment Variables Windows dialog box.

  • Right-click on "My Computer", select Properties, then Advanced (or open the Configuration Panel, open System and security > System). This may require the admin privileges.
  • Click on the "Environment variables..." button on the bottom right.

This button in the red circle in the following figure.

The System Properties dialog box in Windows

  • This opens a dialog box, where the top part present the user variables, and the bottom part present the system variables.

The Environment Variables dialog box in Windows.

  • In the "System variables" pane, find the "PATH" variable and click on the "Edit..." button.
  • Add the following directory at the begining of the PATH:
C:\OpenTURNS\bin;C:\OpenTURNS\lib\bin;[other directories...]

Installing OT+Spyder on Linux

On Linux, the simplest way to install OpenTURNS within Spyder is to use the packaging system of the associated distribution.

Install OpenTurns

This can be done by three ways.

For example, on a Ubuntu distribution, we may use the following commands:

sudo apt-get install python-openturns
sudo apt-get install openturns-examples
sudo apt-get install openturns-validation
sudo apt-get install openturns-wrapper

More details are available at:

http://trac.openturns.org/wiki/HowToInstall

Install Spyder

To install Spyder on Linux, we may use the binaries packaged in the Linux distribution.

For example, on a Ubuntu distribution, we may use the following command:

sudo apt-get install spyder

More details are provided at:

http://code.google.com/p/spyderlib/wiki/Installation

Troubleshooting

In this section, we report common errors when we try to use OpenTURNS from Spyder.

Error: ImportError: No module named openturns

On Windows, we try to import the openturns module in the IPython console of Spyder.

In [1]: from openturns import *
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
ImportError: No module named openturns

The solution is to update the PYTHONPATH variable in order to add the directory where the Python package of OpenTURNS can be found. From the PYTHONPATH dialog box of Spyder, we can add the directory "C:\OpenTURNS\lib\python26\site-packages". See the previous "Let Spyder know OpenTURNS" section above.

Error: ImportError: DLL load failed

On Windows, when we import openturns from Spyder, we get an "ImportError: DLL load failed" error.

In [1]: from openturns import * 
------------------------------------------------------------ 
Traceback (most recent call last): 
  File "<ipython console>", line 1, in <module> 
  File "C:\OpenTURNS\lib\python26\site-packages\openturns\__init__.py", line 89, in <module> 
    from common import * 
  File "C:\OpenTURNS\lib\python26\site-packages\openturns\common.py", line 29, in <module> 
    _common = swig_import_helper() 
  File "C:\OpenTURNS\lib\python26\site-packages\openturns\common.py", line 25, in swig_import_helper 
    _mod = imp.load_module('_common', fp, pathname, description) 
ImportError: DLL load failed: Le module spécifié est introuvable. 

The solution is to update the PATH environment variable in order to add the directories where the OpenTURNS DLLs can be found. See the previous "Update the PATH environment variable" section above.

Another solution is to open a DOS console, and type:

SET PATH=C:\OpenTURNS\bin;C:\OpenTURNS\lib\bin;%PATH%
start C:\Python26\pythonw.exe "C:\Python26\Scripts\spyder"

Debugging an OT script with Spyder

More details on how to debug an OpenTURNS script with Spyder are presented at:

http://trac.openturns.org/wiki/DebugOTScript

Acknowledgments

Thanks to François Deheeger for sharing his .bat script.

Attachments (8)

Download all attachments as: .zip