FEMxDEM saveGauss.py has python2 file() function

Asked by quanm qiu on 2021-03-31

I'm building custom image from registry.gitlab.com/yade-dev/docker-prod:ubuntu20.04.

Some python3-xxx packages were installed into a container image.

When I run FEMxDEM example, I got some warnings and a error related to python version:

/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:54: DeprecationWarning: invalid escape sequence \-
  par.add_argument('--cores',help='Set number of OpenMP threads (as \-\-threads) and in addition set affinity of threads to the cores given. Please provide a string with comma-separated core-ids.',dest='cores',type=str)
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:215: DeprecationWarning: invalid escape sequence \#
  prompt_in1='Yade [\#]: ',
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:216: DeprecationWarning: invalid escape sequence \D
  prompt_in2=' .\D.: ',
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:217: DeprecationWarning: invalid escape sequence \#
  prompt_out=" -> [\#]: ",
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:224: DeprecationWarning: invalid escape sequence \e
  +(['"\e[24~": "\C-Uyade.qt.Controller();\C-M"','"\e[23~": "\C-Uyade.qt.View();\C-M"','"\e[21~": "\C-Uyade.qt.Controller(), yade.qt.View();\C-M"','"\e[20~": "\C-Uyade.qt.Generator();\C-M"'] if (gui!='none') else []) #F12,F11,F10,F9
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:224: DeprecationWarning: invalid escape sequence \e
  +(['"\e[24~": "\C-Uyade.qt.Controller();\C-M"','"\e[23~": "\C-Uyade.qt.View();\C-M"','"\e[21~": "\C-Uyade.qt.Controller(), yade.qt.View();\C-M"','"\e[20~": "\C-Uyade.qt.Generator();\C-M"'] if (gui!='none') else []) #F12,F11,F10,F9
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:224: DeprecationWarning: invalid escape sequence \e
  +(['"\e[24~": "\C-Uyade.qt.Controller();\C-M"','"\e[23~": "\C-Uyade.qt.View();\C-M"','"\e[21~": "\C-Uyade.qt.Controller(), yade.qt.View();\C-M"','"\e[20~": "\C-Uyade.qt.Generator();\C-M"'] if (gui!='none') else []) #F12,F11,F10,F9
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:224: DeprecationWarning: invalid escape sequence \e
  +(['"\e[24~": "\C-Uyade.qt.Controller();\C-M"','"\e[23~": "\C-Uyade.qt.View();\C-M"','"\e[21~": "\C-Uyade.qt.Controller(), yade.qt.View();\C-M"','"\e[20~": "\C-Uyade.qt.Generator();\C-M"'] if (gui!='none') else []) #F12,F11,F10,F9
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:225: DeprecationWarning: invalid escape sequence \e
  +['"\e[19~": "\C-Uimport yade.plot; yade.plot.plot();\C-M"', #F8
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:226: DeprecationWarning: invalid escape sequence \e
  '"\e[A": history-search-backward', '"\e[B": history-search-forward', # incremental history forward/backward
/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/yadeimport.py:226: DeprecationWarning: invalid escape sequence \e
  '"\e[A": history-search-backward', '"\e[B": history-search-forward', # incremental history forward/backward
Warning: no X rendering available (see https://bbs.archlinux.org/viewtopic.php?id=13189)
Kokkos::OpenMP::initialize WARNING: OMP_PROC_BIND environment variable not set
  In general, for best performance with OpenMP 4.0 or better set OMP_PROC_BIND=spread and OMP_PLACES=threads
  For best performance with OpenMP 3.1 set OMP_PROC_BIND=true
  For unit testing set OMP_PROC_BIND=false
Not converged after 0 iteration(s)! Relative error: 1.000000e+00
Not converged after 1 iteration(s)! Relative error: 3.711288e-02
Not converged after 2 iteration(s)! Relative error: 2.028988e-02
Convergence reached after 3 iteration(s)! Relative error: 8.690760e-03
Traceback (most recent call last):
  File "/usr/bin/yade", line 336, in runScript
    execfile(script,globals())
  File "/usr/lib/python3/dist-packages/past/builtins/misc.py", line 87, in execfile
    exec_(code, myglobals, mylocals)
  File "./biaxialSmooth.py", line 94, in <module>
    saveGauss2D(name='./result/gauss/time_'+str(t)+'.dat',strain=strain,stress=stress,fabric=fabric)
  File "/usr/lib/x86_64-linux-gnu/yade/py/yade/FEMxDEM/saveGauss.py", line 8, in saveGauss2D
    fout = file(name,'w')
NameError: name 'file' is not defined

Because the file() builtin function is removed in Python 3. Does it means I can install only python2.7 into the container image if I want to use FEMxDEM?

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
2021-03-31
Last reply:
2021-03-31
Robert Caulk (rcaulk) said : #1

>Because the file() builtin function is removed in Python 3. Does it means I can install only python2.7 into the container image if I want to use FEMxDEM?

Maybe, but it's probably best to convert the script to Python3, which shouldn't be hard [1].

[1]http://yade-dem.org/doc/tutorial-advanced.html#convert-python-2-scripts-to-python-3

Can you help with this problem?

Provide an answer of your own, or ask quanm qiu for more information if necessary.

To post a message you must log in.