question

wl86 avatar image
2 Likes"
wl86 asked wl86 edited

"DLL load failed" when calling Python code using compiled libraries

tl;dr
I get the error "DLL load failed while importing _bz2: The specified module could not be found." when using compiled Python libraries from FlexSim.

Long version
By itself, the connection between FlexSim and Python works: I can call simple test functions in Python from FlexSim and get back the expected result. However, things go wrong as soon as I call code that uses 3rd party libraries. After some trial and error, the problem seems to be specifically with compiled libraries (numpy, ortools, networkx, etc): as soon as FlexSim tries to call a function in a module that imports one of these, I get an error. 3rd Party libraries that are pure Python (e.g. requests), on the other hand, work fine.

Also, testing the relevant code outside of FlexSim, using the same interpreter, works fine.

Any advice on how to proceed would be appreciated!

FlexSim 22.1.4
interaction between flexsim and pythondll load failed
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·
I've used numpy and other packages with FlexSim in the past with no problem. Are you using a standard environment/install? Can you send the file for is to test?


0 Likes 0 ·
wl86 avatar image wl86 commented ·
I currently don't have an active license anymore. As soon as I have one, I will create a minimal example that reproduces the error for me.
0 Likes 0 ·

1 Answer

·
wl86 avatar image
2 Likes"
wl86 answered wl86 edited

Recently it just so happened that I had to switch out my old laptop for a new one; tried running the same model and code on the new laptop and everything works fine.


So the "good" news is that the problem was not with the FlexSim model itself or with my Python code, but with the system environment. Bad news is that the exact root cause remains unknown, and starting with a fully clean slate might be going too far for some people.


Personally I suspect that my old system had gotten cluttered by years of repeated installation and removing of different Python distributions, and frequent creation and removing of Python/Conda distributions; and certainly messing with the Windows PATH variable in roundabout ways (due to not having admin privileges on my system) didn't help...

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.