Welcome to the forums. Please post in English or French.

You are not logged in.

#1 2016-09-28 06:02:44

Kevin-JS
Member
Registered: 2015-07-31
Posts: 19

Can't find the module _aster_core when importing module partition

Hi all,

I am a beginner in using code_aster. What I am trying to do is to calculate a geometry deformation based on a file which gives the pressure of each mesh element. Referring to http://code-aster.org/forum2/viewtopic.php?id=14692 and http://code-aster.org/forum2/viewtopic.php?id=16277, I come up with the idea to resort to python script. However, I was struggling in importing partition module like

Bracchesimo wrote:

import sys
sys.path.append( '/opt/SALOME-MECA-2010.1-x86_64/aster/STA10.1/bibpyt/Utilitai' )
from Utilitai.partition import *
from partition import *

. My python showed that

ImportError: No module named aster_core

. After I appended the path of aster_core to the sys, it came out the error like this

ImportError: No module named _aster_core

. I have searched the whole Salome file and aster file, and found nothing named _aster_core. As I know through the forum, hips of people work on using aster by python and sometimes they should need to import Utilitai.partition. But none of them mentioned the error I encountered with. I assume there is something wrong with my software installation. Could anyone give me a hint? I totally run out out ideas.

Offline

#2 2018-03-13 12:35:42

supersunyan
Member
Registered: 2018-02-12
Posts: 3

Re: Can't find the module _aster_core when importing module partition

Hi Kevin,
I have met the same problem. Have you solved it? If yes, can you share your experience?
Regards,
Yan

Offline

#3 2018-03-13 22:59:21

Kevin-JS
Member
Registered: 2015-07-31
Posts: 19

Re: Can't find the module _aster_core when importing module partition

Hi Yan,

I had this problem when I ran this single command in the Python GUI instead of running it within a whole Aster script. I assume the Utilitai module cannot be used independently. It has to be incorporated in a script.

Kevin

Offline

#4 2020-02-27 19:28:05

Maggoo
Member
From: Rio de Janeiro, Brazil
Registered: 2011-12-21
Posts: 30

Re: Can't find the module _aster_core when importing module partition

Dear colleagues,

I was facing a very similar problem, and solved it by using the 'aster.exe' located at "SALOME-MECA2018\PRODUCTS\code_aster\13.6\bin". I am using the Code-Aster-Windows 2018 here, but the same must apply to Linux installations.

This is a kind of a Python interpreter, but with _aster_core module built in, I guess. It's the only way I can explain why I had the same problem with ordinary Python and using this one the problem vanished.

The issue now is that a certain "aster_core" must be initialized, but I don't know how to make it.

At least the first set of examples of Python access to Aster data shown in the U1.03.02 are working, after the necessary imports.

Best regards and tell us if this advanced your situation, please.

PS: I made some changes in the 'set_env.bat' file which comes with Code-Aster-Windows, and I attach it here hoping to give you a better starting point.

@ECHO OFF

@REM ---------------------------------
@REM Automatic preparation third-party products if need

IF EXIST prepare.bat (
  START /wait prepare.bat
) ELSE (
  ECHO ERROR! Prepare.bat file is not exist!
  ECHO May be problems with compilation or/and using SALOME as third-party product.
  echo Please, check existing of %~dp0\prepare.bat and try again!
)
@REM ---------------------------------

@REM -----edit-if-necessary-----------
@REM Architecture
@SET ARCH=Win64
@REM ---------------------------------

@REM -----edit-if-necessary-----------
@REM Compile mode
@SET BUILD_MODE=Release
@REM ---------------------------------

@REM ---------------------------------
@REM Getting absolute path for SALOME ROOT DIRECTORY
@cd %~dp0..
@SET SALOME_ROOT_DIR=%cd%
@cd %~dp0
@REM ---------------------------------

@REM ---------------------------------
@REM SALOME PRODUCTS DIRECTORY
@SET PDIR=%SALOME_ROOT_DIR%\PRODUCTS
@SET DESTINATION_DIR=RELEASE
@REM ---------------------------------

@SET PATH=%SALOME_ROOT_DIR%\MODULES\exe;%PATH%
@SET PATH=%SALOME_ROOT_DIR%\MODULES\dll;%PATH%

@REM ---------------------------------
@REM HOME DIRECTORY
@SET HOME=%userprofile%
@SET SALOME_TMP_DIR=%SALOME_ROOT_DIR%\TMP
@REM ---------------------------------

@REM ---------------------------------
@REM SALOME DATA DIRECTORY
@SET DATA_DIR=%SALOME_ROOT_DIR%\SAMPLES

@SET list=(LIBBATCH KERNEL GUI GEOM MEDCOUPLING MED SMESH YACS JOBMANAGER PARAVIS HEXABLOCK HEXABLOCKPLUGIN NETGENPLUGIN GHS3DPLUGIN HEXOTICPLUGIN BLSURFPLUGIN ATOMGEN ATOMIC ATOMSOLV PYCALCULATOR CALCULATOR COMPONENT LIGHT PYLIGHT RANDOMIZER SIERPINSKY PYHELLO HELLO HYBRIDPLUGIN ASTERSTUDY)
for %%i in %list% do (
 
  SET %%i_ROOT=%SALOME_ROOT_DIR%\MODULES\%%i\%DESTINATION_DIR%
  SET %%i_BUILD_DIR=%SALOME_ROOT_DIR%\MODULES\%%i\%DESTINATION_DIR%\%%i_BUILD
   
  setlocal ENABLEDELAYEDEXPANSION
    IF NOT EXIST "!%%i_BUILD_DIR!" mkdir "!%%i_BUILD_DIR!"
    cd "!%%i_BUILD_DIR!"
  endlocal

  SET %%i_ROOT_DIR=%SALOME_ROOT_DIR%\MODULES\%%i\%DESTINATION_DIR%\%%i_INSTALL
  SET %%i_SRC_DIR=%SALOME_ROOT_DIR%\MODULES\%%i\%%i_SRC
)
SET CONFIGURATION_ROOT_DIR=%SALOME_ROOT_DIR%\MODULES\CONFIGURATION
IF NOT EXIST "%CONFIGURATION_ROOT_DIR%" mkdir "%CONFIGURATION_ROOT_DIR%"
rem SET PATH=%LIBBATCH_ROOT_DIR%\lib;%PATH%
rem SET PATH=%MEDCOUPLING_ROOT_DIR%\lib;%PATH%
@SET PYTHONPATH=%MEDCOUPLING_ROOT_DIR%\lib\python2.7\site-packages;%PYTHONPATH%
@SET PYTHONPATH=%MEDCOUPLING_ROOT_DIR%\bin;%PYTHONPATH%
SET VTK_AUTOLOAD_PATH=%GUI_ROOT_DIR%\lib\paraview
@SET PV_PLUGIN_PATH=%PV_PLUGIN_PATH%;%PARAVIS_ROOT_DIR%\lib\paraview

REM ================================
rem Setting PATH, PYTHONPATH for modules.
rem Only for KERNEL, GUI, MED, PARAVIS modules environment will be set automatically.
rem If you need to set the environment for some other modules, edit env_m_list.
rem Full env_m_list is (KERNEL GUI GEOM MED SMESH YACS JOBMANAGER PARAVIS HEXABLOCK HEXABLOCKPLUGIN NETGENPLUGIN GHS3DPLUGIN HexoticPLUGIN BLSURFPLUGIN ATOMGEN ATOMIC ATOMSOLV PYCALCULATOR CALCULATOR COMPONENT LIGHT PYLIGHT RANDOMIZER SIERPINSKY PYHELLO HELLO)

SET env_m_list=(KERNEL, GUI, MED, PARAVIS)
FOR %%j in %env_m_list% DO (
  call "set_one_module_env.bat" %%j
)
REM ================================

REM set DEBUG=1

REM ***** ALTERACAO HELIOCBORTOLON ******
REM :: created by waf using data/wscript
set ASTER_ROOT=C:\Users\cxzh\Pessoais\SALOME-MECA2018\PRODUCTS\code_aster
set PYTHONPATH=%ASTER_ROOT%\13.6\lib\aster;%ASTER_ROOT%\lib\python2.7\site-packages;%PYTHONPATH%

set ASTER_DATADIR=%ASTER_ROOT%\13.6\share\aster
set ASTER_LIBDIR=%ASTER_ROOT%\13.6\lib\aster
set ASTER_LOCALEDIR=%ASTER_ROOT%\13.6\share\locale\aster
set ASTER_ELEMENTSDIR=%ASTER_ROOT%\13.6\lib\aster

set PATH=%ASTER_ROOT%\13.6\bin;%PATH%
REM ***** ALTERACAO HELIOCBORTOLON ******

Last edited by Maggoo (2020-02-27 19:30:04)


---------------------------------------------------
Helio Carlos Bortolon,
Mech Engr, M.Eng. and Maggoo
---------------------------------------------------

Offline