xcfem / xc

finite element analysis package for civil engineering structures.
http://www.xcengineering.xyz/html_files/software.html
GNU General Public License v3.0
262 stars 54 forks source link

AttributeError: 'str' object has no attribute 'removeprefix' #128

Closed ebrahimraeyat closed 3 months ago

ebrahimraeyat commented 3 months ago

Hi @lcpt . I compiled xc and run verification tests. It gives me a lot of error due to 'str' object has no attribute 'removeprefix' or 'removesuffix'. It seems it's introduce in python version 3.9+

To Reproduce Run this test: Traceback (most recent call last):

  File "tests/utility/misc_utils/test_xc_json_01.py", line 29, in <module>
    xcData= json.loads(rawData, cls=xc_json.XCJSONDecoder)
  File "/usr/lib/python3.8/json/__init__.py", line 370, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
  File "/usr/local/lib/python3.8/dist-packages/misc_utils/xc_json.py", line 173, in object_hook
    retval= self.broke_object(objId= objId, fullyQualifiedClassName= dct['class_name'], tag= tag, name= name, dct= dct)
  File "/usr/local/lib/python3.8/dist-packages/misc_utils/xc_json.py", line 144, in broke_object
    moduleName= fullyQualifiedClassName.removesuffix('.'+className)
AttributeError: 'str' object has no attribute 'removesuffix'

windows 11 with wsl2.

>>> xc.getXCVersion()
'v0.12-7017-g9ea01f994'
>>>
lcpt commented 3 months ago

According to this, removeprefix was added to string class in Python 3.9. The current Python version in Ubuntu 22.04 is 3.10.12. What version of Python are you running?

ebrahimraeyat commented 3 months ago

yes, I use python 3.8.10

root@DESKTOP-7AJHP3M:/home/ebrahim/xc_soleh# python
Python 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

I will update my ubuntu or python. Thanks.

ebrahimraeyat commented 3 months ago

I updated my ubuntu system and python. But can't compile correctly:

[ 99%] Building CXX object CMakeFiles/XcBib.dir/FEProblem.cc.o
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/librt.so', needed by '/home/ebrahim/xc/lib/libXcBib.so'.  Stop.
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:178: CMakeFiles/XcBib.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I also run this command to update required packages:

sudo bash packages_install_ubuntu_focal_fossa.sh

errors:

root@DESKTOP-7AJHP3M:/home/ebrahim/build_xc# make -j 4
Scanning dependencies of target xc_basic_utils
Consolidate compiler generated dependencies of target xc_basic_utils
[  7%] Built target xc_basic_utils
Consolidate compiler generated dependencies of target xc_utils
[ 18%] Built target xc_utils
Consolidate compiler generated dependencies of target xc_base
Consolidate compiler generated dependencies of target xcGnuGts
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libpthread.so', needed by '/home/ebrahim/xc/lib/libxc_base.so'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:205: CMakeFiles/xc_base.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Consolidate compiler generated dependencies of target geom
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libpthread.so', needed by '/home/ebrahim/xc/lib/libxcGnuGts.so'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:259: CMakeFiles/xcGnuGts.dir/all] Error 2
Scanning dependencies of target XcBib
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libpthread.so', needed by '/home/ebrahim/xc/lib/libgeom.so'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:232: CMakeFiles/geom.dir/all] Error 2
Consolidate compiler generated dependencies of target XcBib
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/librt.so', needed by '/home/ebrahim/xc/lib/libXcBib.so'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:178: CMakeFiles/XcBib.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
root@DESKTOP-7AJHP3M:/home/ebrahim/build_xc#

Thanks

lcpt commented 3 months ago

Hi, @ebrahimraeyat.

This is weird. The libraries in the /usr/lib/86_64-linux-gnu directory make part of the OS and, for example, librt.so belongs to the libc6 package which is needed to compile and link programs which use the standard C library (and XC libraries uses it, of course). I think something went wrong during the installation of the required packages.

Anyway, this has nothing to do with the original issue, so I will close it. Open another one if you need to.

ebrahimraeyat commented 3 months ago

Thanks, you are right.