Issue in module import

54 views
Skip to first unread message

Clément Raynaud

unread,
Mar 11, 2024, 7:09:42 AM3/11/24
to FeResPost
Hey everyone !

I am just discovering FeResPost to manipulate SAMCEF code using Python.
I followed the different steps mentioned in the manual for the installation but I am facing a problem when I run the first example.

I put the FeResPost.pyd file in Anaconda3.9/Lib/site-packages/FeResPost, so the first lines are working :

import FeResPost
from FeResPost import *

But the Post module seems undefined (you can see it on the screenshot, in the Python console). The same thing happens with the module NastranDb module.

I read many times the manual and explored the Google group but I cannot find anything about it. I also tried to modify the env.bat file with the correct paths but it still doesn’t work.

I am sure it is just a detail I missed, since it is the first time I do such a manipulation.

Thanks for your help,

Regards, 

Clément Raynaud

screen1.png

FeResPost

unread,
Mar 11, 2024, 2:00:18 PM3/11/24
to FeResPost
Hi Clément,

I Just made a few tests with Python extensions, and I experience the same kind of difficulties. Probably, Python does not load FeResPost.pyd for a missing dependency?

Unfortunately, I do not have much time to spend on the subject until next weekend. I Hope you can wait until next week for an answer.

Regards,

Renaud

FeResPost

unread,
Mar 12, 2024, 2:19:59 AM3/12/24
to FeResPost
Clément,

I have the confirmation that the failure of loading FeResPost library is related to dynamic library dependencies. When I use version 5.0.6b, I can load the library. Version 5.0.6b is compiled with "-static" option and uses the static libraries whenever possible.

I propose you try to learn FeResPost using version 5.0.6b. I will investigate the dynamic librariy dependencies this weekend.

Regards,

Renaud

Clément Raynaud

unread,
Mar 12, 2024, 4:52:34 AM3/12/24
to FeResPost
Hi Renaud,

Thanks for this quick response !

When I use version 5.0.6b (or 5.0.6 or 5.0.5) I can load the library (with import FeResPost) but I am facing the same issue : name 'Post' is not defined.
Did I miss something ?

I can wait until next week, I am investigating on my side too.

Regards,

Clément

Nikolai Zhivotenko

unread,
Mar 12, 2024, 8:54:33 AM3/12/24
to fere...@googlegroups.com
This may sound silly, but have you tried replacing ‘Post’ with ‘FeResPost'? It looks very much like a typo. Or are you loading the ‘Post’ module specifically?

Вт, 12 марта 2024 г. в 11:52, Clément Raynaud <clem...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "FeResPost" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ferespost+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ferespost/dc570fb4-af51-4248-b461-5a9e36d6822cn%40googlegroups.com.

Clément Raynaud

unread,
Mar 12, 2024, 9:24:18 AM3/12/24
to FeResPost
'Post' is the name of a class in FeResPost (I admit the example was not the best one).
And the call to 'NastranDb' (another class constructor) next line does not work either.

(I am trying to run the first example shared in the example repository)

FeResPost

unread,
Mar 12, 2024, 12:58:40 PM3/12/24
to FeResPost
Hello,

I do not think the problem can be related to a confusion between "Post" module and "FeResPost" library because the code in Clément's image is correct.

Possible explanations for the non loading of FeResPost can be:
  1. One forgets to install the library.
  2. One installs the wrong library (for example trying to load a 32 bits library instead of a 64 bits one, or a LINUX one instead of a Windows one, mismatch of Python version and FeResPost libray, or...).
  3. One does not properly initializes environment variables, like library paths in the execution environment.
  4. There is a problem in the library, like broken dependencies.
  5. ...
I consider the explanation in point 4 like the most probable explanation, because that it the problem I have with version 5.0.7 (library linked without the "-static" option). Then, I have the following error message when I try to load the library:

C:\Users\ferespost\Documents\TESTSAT\PYTHON\EX01>python readBdf.py
Traceback (most recent call last):
  File "readBdf.py", line 4, in <module>
    import FeResPost
ImportError: DLL load failed while importing FeResPost: Le module spécifié est introuvable.

Note that the message specifically says that the import of FeResPost library failed, not only the "Post'" module. When I replace the library (FeResPost.pyd file), by the one from version 5.0.6b, everything works fine (even the exception, in this example).

Meanwhile, I suggest different approaches to progress with the resolution of this problem:
  • Try launching Python via batch files instead of anaconda. Error messages seem more accurate. This might help you to identify the source of the problem. I suggest you test this with version 5.0.6b.
  • Use ruby instead of Python. I do not have problems with ruby, even when using FeResPost version 5.0.7. At least you can learn FeResPost, even though via ruby extension.
  • Compile your own version of Python library using of the makefiles delivered with the sources. This is not too difficult on UNIX/LINUX machines as compilers are generally already installed.
Good luck,

Renaud





Clément Raynaud

unread,
Mar 13, 2024, 5:18:14 AM3/13/24
to FeResPost
Hi Renaud,

Thank you for your time.

When you are trying version 5.0.7, you cannot load the library ?
Because on my computer, I put the “FeResPost.pyd” file in the following directory : “Lib\site-packages\FeResPost”
And the command “import FeResPost” did not generate an error. The error happens when I am trying to use the library, it is like nothing from the library is defined.

However, I had an error message similar to yours ("ImportError: DDL load failed while importing FeResPost: Le module spécifié est introuvable") when I tried the first time, and I resolved it by removing the path (in sys.path) “files\FeResPost\OUTPUT\PYTHON\PYTHON_39” that I had added before. It is quite strange but this error message never reappeared.

And I got the exam same thing with version 5.0.6.
It is possible something went wrong on my side, but I am still going to try and make it work.

Regards,

Clément

FeResPost

unread,
Mar 13, 2024, 1:23:12 PM3/13/24
to FeResPost
Hi Clément,

Indeed, I have the problem with version 5.0.7 but not with version 5.0.6. In my case, the problem seems related to missing DLL dependencies when using version 5.0.7.

I think it would be interesting for you to test the two versions, but not via Anaconda. I suspect Anaconda hides some error messages. You will have to tune the environment variables. (See the batch files given as examples.)

Renaud

Clément Raynaud

unread,
Mar 15, 2024, 7:06:37 AM3/15/24
to FeResPost
Hi Renaud,

Thank you for all your answers !

I tried with another interpretor but I got the same problem (for both versions).

I re-read this conversation on the Google Group and tried a new approach.
Rather than runnning the code readBdf.py from a Python IDE, I used this script in the command prompt :

setlocal

set PYTHONPATH=C:/Users/Raynaud/Desktop/FeResPost/FeResPost_win64_5.0.6b/OUTPUTS/PYTHON/PYTHON_311
set PYTHONINSTALLDIR=C:/Users/Raynaud/AppData/Local/Programs/Python/Python311
set REDISTRPATH=C:/Users/Raynaud/Desktop/FeResPost/FeResPost_win64_5.0.6b/OUTPUTS/REDISTR
set PATH=%PYTHONINSTALLDIR%;%REDISTRPATH%

python readBdf.py
endlocal


And it worked ! With both versions (5.0.6b and 5.0.7).
I thought that moving the FeResPos.pyd file from the downloaded directory to the Lib/site-packages directory was sufficient.

So now it is possible to use the library this way, but if I want to use a Python IDE, I have to run a first code that defines the environnement and then calls the readBdf.py file (you can see it on the first screen). But, if I want to do it in the same .py file I get the same error again (you can see it on the second screen).

I still don't understand why this happens, and it's still a problem since you don't have access to the IDE's "documentation" or check syntax when you are coding.

If anyone finds a solution to this problem, please let me know !

Regards,

Clément
screen1.png
screen2.png

FeResPost

unread,
Mar 15, 2024, 11:52:24 AM3/15/24
to FeResPost
Hello Clément,

I see you are progressing. The problem was clearly related to the definition of environment variables.

If you want to use FeResPost directly from anaconda you could try one of these two solutions:
  • Launch anaconda from a batch file in which you first define the environment variables.
  • Define these variables in your user profile.
That said, I am not an expert in anaconda or other IDEs. You should adress questions regarding the configuration of these IDEs to the appropriate discussion groups.

Have a good weekend,

Renaud
Reply all
Reply to author
Forward
0 new messages