a problem for building escript on ubuntu18.04

Asked by mingchun lin

Hi, sir:

    I'd like to build escript on ubuntu18.04 (with python3.6), but there is a problem when I ran "scons -j1 options_file=scons/templates/bionic_py3_options.py". The error is shown as follow:

-------

hp@ubuntu:~/python_escript_5_6.1/src$ scons -j1 options_file=scons/templates/bionic_py3_options.py
scons: Reading SConscript files ...
3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0]
TypeError: a bytes-like object is required, not 'str':
  File "/home/lmc/python_escript_5_6.1/src/SConstruct", line 173:
    ENV = {'PATH': os.environ['PATH']})
  File "/usr/lib/scons/SCons/Environment.py", line 965:
    variables.Update(self)
  File "/usr/lib/scons/SCons/Variables/__init__.py", line 184:
    exec(contents, {}, values)
  File "<string>", line 48:

  File "<string>", line 48:

-------

    what should I do? I'm looking forward to your reply.
    Thank you very much :-)

Question information

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

Hi Mingchun,

I set up a VM with Ubuntu 18.04 and was able to successfully compile escript from source without any issues. Are you using the bionic_py3_options.py file that came with the source code?

Could you please try to compile escript using the command:
scons -j4 pythoncmd=/usr/bin/python3 boost_libs=libboost_python3-py36 openmp=1

Adam

Revision history for this message
mingchun lin (lin03) said :
#2

Hi Adam,

I'm sure the bionic_py3_options.py file came from source code. I try the command that you suggested, but it appears another problem:

----

hp@ubuntu:~/python_escript_5_6.1/src$ scons -j4 pythoncmd=/usr/bin/python3 boost_libs=libboost_python3-py36 openmp=1
scons: Reading SConscript files ...
3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0]

WARNING:
Options file /home/lmc/python_escript_5_6.1/src/scons/ubuntu_options.py
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.

/bin/sh: 1: svnversion: not found
Checking whether the C++ compiler works... yes
Checking for C++ function gethostname()... yes
Checking for C++ header file byteswap.h... yes
Checking for C++ function SCbswap32()... yes
Checking for C++ header file sys/endian.h... no
Checking for C++ header file libkern/OSByteOrder.h... no
Checking for working complex std::acos()... yes
Checking for C++ header file Python.h... no
Cannot find python include files (tried 'Python.h' in directory b'/usr/include/python3.6m')

----

I still don't know why it doesn't work...

Mingchun

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

Okay, could you please try running

scons -j4 pythoncmd=/usr/bin/python3 boost_libs=libboost_python3-py36 openmp=1 pythonlibname=python3.6m pythonlibpath=/usr/lib/x86_64-linux-gnu pythonincpath=/usr/include/python3.6m

Revision history for this message
mingchun lin (lin03) said :
#4

Hi Adam,

The second command worked! But I can't call escript in python-terminal by using "from esys.escript import * ". It shows "MoudleNotFoundError: No module named 'esys'.

It did notice build successfully, is there something missed?

Revision history for this message
mingchun lin (lin03) said :
#5

Thanks Adam Ellery, that solved my question.

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

Hi Mingchun,

It looks like escript has successfully compiled on your computer but your python interpreter does not know where to find the files.

If you navigate to the folder src and then run the command
bin/run-escript -e
escript will print some console output that tells you how to modify your environment so that python knows where to find escript.

The command
bin/run-escript -e >> ~/.bashrc
will copy this console output to the bottom of your bashrc file. If you do this then every time you open a new terminal window, the environment will be automatically set up for you.

- Adam

Revision history for this message
mingchun lin (lin03) said :
#7

Hi Adam,

I tried to export the PYTHONPATH and LD_LIBRARY_PATH before enter python interpreter, and it can find the src folder :-)

May I ask another question here?
I'd like to apply escript in YADE to realize FEM-DEM couple simulation. When I ran the script in yade, it turned out this:

---

Running script biaxialSmooth.py
=======================================================================
For better performance compile python-escript with direct solver method
=======================================================================
Press Enter to continue...

---

It seems the direct solve function was not been built. What should I do? (How can I add the options when build escript in my case?)

Thank you for your patience.

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

There are several direct solvers that are available for escript. The easiest one to install in Ubuntu is umfpack.

Create a file name ubuntu_options.py in the scons folder (i.e. scons/ubuntu_options.py) then paste in the following text:

escript_opts_version=203
pythoncmd='/usr/bin/python3'
boost_libs='libboost_python3-py36'
openmp=1
pythonlibname='python3.6m'
pythonlibpath='/usr/lib/x86_64-linux-gnu'
pythonincpath='/usr/include/'
umfpack=1
umfpack=['/usr/include/suitesparse','/usr/lib/c86_64-linux-gnu/']

Then run
scons -j8

Once it has finished compiling, there should be a line in the output that says "Direct Solver: YES (umfpack)".

Revision history for this message
mingchun lin (lin03) said :
#9

Hi Adam,

It seems doesn't work... I create the ubuntu_options.py file and run 'scons -j8', then the 'cannot find python.h' shows again.

If I add the python's options (i.e., pythoncmd, pythonlibname, etc.) after '-j8 ' , it will pass the ubuntu_options.py and compile without direct solver like before...

 If I try this:

scons -j8 pythoncmd=/usr/bin/python3 boost_libs=libboost_python3-py36 openmp=1 pythonlibname=python3.6m pythonlibpath=/usr/lib/x86_64-linux-gnu pythonincpath=/usr/include/python3.6m umfpack=1 umfpack_prefix=/usr/include/suitesparse:/usr/lib/x86_64-linux-gnu umfpack_libs=['umfpack','blas','amd']

it shows :

scons: Reading SConscript files ...
3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0]

WARNING:
Options file /home/lmc/src/scons/lmc_hp_elitebook_840_g6_options.py
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.

/bin/sh: 1: svnversion: not found
Checking whether the C++ compiler works... (cached) yes
Checking for C++ function gethostname()... (cached) yes
Checking for C++ header file byteswap.h... (cached) yes
Checking for C++ function SCbswap32()... (cached) yes
Checking for C++ header file sys/endian.h... (cached) no
Checking for C++ header file libkern/OSByteOrder.h... (cached) no
Checking for working complex std::acos()... (cached) yes
Checking for C++ header file Python.h... (cached) yes
Checking for C++ function Py_Exit()... (cached) yes
Checking for C++ library libboost_python3-py36... (cached) yes
Checking for C++ library libboost_python3-py36... (cached) yes
Found boost/python/numpy.hpp. Building with boost numpy support.
Checking for C++ header file numpy/ndarrayobject.h... (cached) yes
RuntimeError: umfpack.h not found under /usr/include/suitesparse:/usr/lib/x86_64-linux-gnu:
  File "/home/lmc/src/SConstruct", line 525:
    env=checkOptionalLibraries(env)
  File "/home/lmc/src/site_scons/dependencies.py", line 593:
    umfpack_inc_path,umfpack_lib_path=findLibWithHeader(env, env['umfpack_libs'], 'umfpack.h', env['umfpack_prefix'], lang='c++')
  File "/home/lmc/src/site_scons/site_init.py", line 51:
    raise RuntimeError('%s not found under %s'%(header,paths))

The umfpack.h file does under the folder '/usr/include/suitesparse'.

Thanks again!

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

After creating scons/ubuntu_options.py, did you try running

scons -j8 options_file=scons/ubuntu_options.py

?

Revision history for this message
mingchun lin (lin03) said :
#11

I tried... And error is:

lmc@lmc-hp-elitebook-840-g6:~/src$ scons -j8 options_file=scons/ubuntu_options.py
scons: Reading SConscript files ...
3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0]

scons: *** Error converting option: umfpack
Invalid value for boolean option: /usr/include/suitesparse /usr/lib/x86_64-linux-gnu/
File "/home/lmc/src/SConstruct", line 173, in <module>

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

I apologise. I made a mistake when typing this in.

The lines
umfpack=1
umfpack=['/usr/include/suitesparse','/usr/lib/c86_64-linux-gnu/']

Should actually be
umfpack=1
umfpack_prefix=['/usr/include/suitesparse','/usr/lib/c86_64-linux-gnu/']

Revision history for this message
mingchun lin (lin03) said :
#13

Thanks Adam, it succeed!! I really appreciate it :-D