Theil-Sen estimated median change in rain normalised soil moisture 2001-2016, Indonesia

Map: Theil-Sen estimated median change in rain normalised soil moisture 2001-2016, Indonesia

Eclipse for PyDev

Thomas Gumbricht bio photo By Thomas Gumbricht

Introduction

To run the python scripts for importing, plotting and modelling OSSL data as described in other posts of this blog you need to have a python development environment. This post describes how to setup a python environment using Eclipse. The instructions are shorthand and written using MacOS. I have also published more detailed instructions for setting up Eclipse for MacOS and a summary for how to install Eclipse and Anaconda in Ubuntu20.

Eclipse

Eclipse is “an open extensible IDE for anything and nothing in particular”, where IDE stands for Integrated Development Environment. We will use Eclipse for testing and developing the python scripts used for processing OSSL data.

Open a browser and go to Eclipse foundation. Look for the (orange) Download button. You should come directly to the download page for your OS. At time of writing this in September 2023 the latest version of Eclipse is 2023-06. Select the version that is appropriate for your machine architecture and go ahead and download (figure 1).

image
Figure 1. Select the Eclipse version that is appropriate for your machine architecture.

The later versions of the Eclipse installations packages are all inclusive. The installation package is rather small and should download quickly (figure 2).

image
Figure 2. The later versions of the Eclipse installation package includes the Java Runtime Environment required for your OS.

Eclipse_installer_app

Open the installation app that was downloaded and run it - the example to the right shows the MacOS Eclipse installation app icon. Just double click and the installation of Eclipse itself should start.

It might take a while for the installer to get going (figure 3).

image
Figure 3. Waiting for the Eclipse installer app to load.

When presented with different alternatives to install, chose the Eclipse IDE for Java Developers alternative.

image
Figure 4. Choose the Eclipse IDE for Java Developers when asked for version to install.

After selecting the installation version, the next window will summarise your choice and the destination paths of your installation (figure 5).

image
Figure 5. Summary of selected installation and destination paths for installation, press Install to start the installation.

Click Install. When the installation is ready, the Eclipse installer window changes and you can launch (or inspect) the Eclipse installation (figure 6).

image
Figure 6. Launch Eclipse (or open the readme/explore the installation).

The first time you start, Eclipse will ask you to Select a directory as workspace. You can usually accept the default, but as I have older versions installed I set a specific workspace for each version as shown in figure 7.

image
Figure 7. Select a directory as workspace.

Once you have selected the directory for the workbench, the next window is the Welcome to the Eclipse IDE for ... Before proceeding you have to Launch the Eclipse Marketplace (figure 8).

image
Figure 8. Eclipse Welcome window - before continuing Launch the Eclipse Marketplace.

In the Eclipse Marketplace window, enter the search term pydev in the Find field and click the Go button in the top row. The top result should then be the PyDev extension (figure 9). Click the Install button for the PyDev extension.

image
Figure 9. In Eclipse Marketplace find the PyDev extension and then click install.

In the sequence of windows that follows (figures 10 to 13) you must confirm, bypass and accept various conditions to follow the installation through.

image
Figure 10. In Eclipse Marketplace confirm the installation of the PyDev extension.
image
Figure 11. In Eclipse Marketplace for MacOS the Marketplace installation of PyDev reports an error, but by accepting to proceed the installation anyway finishes correctly.
image
Figure 12. You must accept the license terms in order to proceed with the PyDev extension installation.
image
Figure 13. You must state that you trust the authorities in order to proceed with the PyDev extension installation.

Once the PyDev extension is installed, Eclipse needs to be restarted for the installation to be activated. In the window asking if you want to restart click the button Restart Now (figure 14).

image
Figure 14. Restart Eclipse to activate the PyDev extension.

Eclipse_welcome_hide

Once has restarted you will again come to the Welcome to the Eclipse IDE for .. window. This time you just bypass (hide) the Welcome window by clicking the little hide icon in the upper right corner (shown to the right).

An Eclipse project window opens (figure 15).

image
Figure 15. Eclipse project window.

To continue you must have cloned or downloaded the python OSSL package from GitHub as explained in a previous post.

To import the python OSSL package, either click Import projects in the Package Explorer tab (the left main column), or go via the menu:

File -> Import

In the Import window, expand the General folder and then select Projects from Folder or Archive as shown in figure 16.

image
Figure 16. Expand import options to get the alternative "Projects from Folder or Archive".

This should hihglight the (blue) Next > button, click it to proceed. In the next, Import Projects window, select the (white) Directory… button (figure 17) and navigate to the path where you saved the clone/download of the OSSL-pydev repo. Under that path, select the folder ossl-xspectre (the folder that is also contains the hidden Eclipse files .project and .pydevproject) (figure 17).

image
Figure 17. Select the ossl-xspectre package that you cloned/donwloaded in a previous post.

Click Finish. You should then get an error message “Python not configured” (figure 18). What Eclipse is asking for is the virtual environment that you created in the previous post.

image
Figure 18. You have to manually set the python environment to the virtual environment you created with Anaconda in a previous post.

In the Python not configured window, click the (blue) button Manual config. In the Preferences window that opens, click the button New at the top of the right column and select the alternative Browse for python/pypy exe (figure 19).

image
Figure 19. In the Eclipse Preferences window select New in the top right column, then Browse for python/pypy exe and navigate to the virtual python environment you created using Anaconda.

Navigate to the virtual Python environment you created with Anaconda. It is under the Anaconda installation directory, in a subfolder called envs. Under envs you should have another subfolder with the name of the environment you created (e.g. “ossl_py38” if you used the suggested name in the post on Anaconda). The python/pyp exe file is under the bin folder and called python3.8. The relative path under your Anaconda installation should thus be:

anaconda3 -> envs -> ossl_py38 -> bin ->python3.8

In my system (MacOS) it looks like this when I have selected the python3.8 exe file (figure 20).

image
Figure 20. Eclipse selected interpreter with the Anaconda virtual environment created in an earlier post selected.

Click OK, then click OK again in the Selection needed window (figure 21)

image
Figure 21. Confirm the interpreter selection in the Selection needed window.

You should then get back to the Preferences window. Click Apply and Close.

Finally you get back to Eclipse project window. In the left column package explorer you should see the pydev package ossl-xspectre. Expand to see the content by clicking on it, this will first cause a popup window asking for your Default Preferences for PyDev in Eclipse. Accepting the defaults by clicking OK is recommended.

To run the scripts (python modules) go to the next post that explains how to link the script to OSSL data and edit the command files required.