use of run-escript on terminal window

Asked by Jiayao Wang

Hi, I am quite new to Esys Escript, I have the following problem when I tried to run the
( is simply the first example of one dimensional heat diffusion in Granite in the Cookbook.)

I simply open a terminal window in the folder where is located, and type $ run-escript, it gives me the following error.

jiayao@jiayao-VirtualBox:~/Documents/Esys Escript examples$ run-escript
Traceback (most recent call last):
  File "", line 1, in <module>
    from esys.escript import *
ModuleNotFoundError: No module named 'esys.escript'

Is it the correct way to run esys-escript? If so , how could I fix the problem? Thanks.

A side question: There aren't any examples scripts in the, where can I find example scripts in the cookbook?

Question information

English Edit question
esys-escript Edit question
No assignee Edit question
Solved by:
Adam Ellery
Last query:
Last reply:
Revision history for this message
Adam Ellery (aellery) said :

Hi Jiayao,

In order to run escript on Linux, you first need to compile it. As a preliminary step, you need to install the dependencies that escript requires in order to run. There are a list of the packages that contain these dependencies, for several linux distributions, in the install guide. I am happy to help you locate the packages you need if you are using a linux distribution that is not listed there.

Once the packages are installed, you can compile escript by navigating to the folder that contains the source code and running the command:
scons options_file=scons/templates/
where is the scons options file for your distribution. If there is no options file available, I am happy to help you create one.

After escript has been compiled, you can run it by either (i) running the file "run-escript" which is located in the bin folder; or (ii) adding the escript library files to PATH so that your python interpreter can locate them (This can be easily done with the command "eval `run-escript -e`".)

All of the example scripts used by the cookbook are located in the folder:

Revision history for this message
Jiayao Wang (jiayaowang07) said :

Hi, Adam, thank you for your answer, but I am still a little confused.

I installed esys-escript from flatpak, I thought I don't need to download the source code this way. If I type "flatpak run" in a command windows, it appears:
jiayao@jiayao-VirtualBox:~$ flatpak run
Python 3.7.2 (default, Aug 7 2020, 00:49:46)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
This should mean I have downloaded it successfully, right?

To follow your guidelines, I downloaded python_escript_5.6.tar.gz, and unzipped it to a folder called src. I navigated command window to src folder and ran "scons options_file=scons/templates/", it gave me the following error. Indeed, I checked there is no in scons/templates. Is it the problem?
jiayao@jiayao-VirtualBox:~/Downloads/src$ scons options_file=scons/templates/
scons: Reading SConscript files ...
3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0]

Options file scons/templates/
not found! Default options will be used which is most likely suboptimal.
We recommend that you copy the most relavent options file in the scons/template/
subdirectory and customize it to your needs.

scons: *** File path for option options_file does not exist: scons/templates/
File "/home/jiayao/Downloads/src/SConstruct", line 172, in <module>

And to look one step ahead, you suggested to run it with two ways. I have problem with either of them. (i) there is no file located in the bin folder; (ii) if I want to add files to PATH on ubuntu, I found the following instructions, the weird thing is that I cannot find .bashrc file on ubuntu. I use Oracle VM VirtualBox to run ubuntu:
    (1)Open the .bashrc file in your home directory (for example, /home/your-user-name/.bashrc) in a text editor.
    (2)Add export PATH="your-dir:$PATH" to the last line of the file, where your-dir is the directory you want to add.
    (3)Save the .bashrc file.
    (4)Restart your terminal.

Thank you again for your kind help.

Revision history for this message
Best Adam Ellery (aellery) said :

Hi Jiayao,

I am sorry, I misunderstood your original question. You are correct, if you install escript using the flatpak then you do not need to compile escript yourself from the source code.

Unfortunately, the python scripts for the examples do not come with the flatpak. However they are packaged in the source code tarball and once the tarball has been extracted they can be located in the folder /doc/examples/. If you have installed escript on your machine using the flatpak, you can run escript on these examples using the command

flatpak run [python script]

For example, to run escript on in the cookbook, you should navigate to the folder containing this file and then type

flatpak run

- Adam

Revision history for this message
Jiayao Wang (jiayaowang07) said :

Hi, Adam, thank you very much. That helps. Much appreciated!

Revision history for this message
Jiayao Wang (jiayaowang07) said :

Thanks Adam Ellery, that solved my question.