Can I install/use numpy in CFD API?

Can I install/use numpy in CFD API?

luke_allen9FV6X
Explorer Explorer
602 Views
4 Replies
Message 1 of 5

Can I install/use numpy in CFD API?

luke_allen9FV6X
Explorer
Explorer

Hi everyone! 

 

I am working on automating some analyses of results using the Python API. It would be very useful if I could install, or link to, external data science libraries (e.g., numpy) from CFD Python. So far, I have been unsuccessful. 

 

I've tried the following:

  • Install same version of Python that CFD uses (3.8) in another location on my system
  • Install numpy using new interpreter (via pip)
  • From CFD Python, add the numpy install location to the search path using sys.path.append("path/to/python3.8/Lib/site-packages").

This procedure does allow the CFD Python interpreter to find the packages installed for the other interpreter. I can even import external packages written in pure Python. However, numpy fails to import. Likewise, anything with numpy as a dependency (e.g., pandas, scipy) also fails. The issue appears to be a problem importing numpy's C-extensions. Below is the error output:

 

"""

ImportError:

 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

 

Importing the numpy C-extensions failed. This error can happen for

many reasons, often due to issues with your setup or how NumPy was

installed.

 

We have compiled some common reasons and troubleshooting tips at:

 

https://numpy.org/devdocs/user/troubleshooting-importerror.html

 

Please note and check the following:

 

* The Python version is: Python3.8 from "C:\Program Files\Autodesk\CFD 2021\CFD.exe"

* The NumPy version is: "1.24.3"

 

and make sure that they are the versions you expect.

Please carefully study the documentation linked above for further help.

 

Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.

"""

 

I checked out troubleshooting guide mentioned in the error message. Unfortunately, it's not really applicable since I have no control over CFD's bundled Python installation.

 

Has anyone else encountered this? Or have suggestions? I am an experienced Python user with a fair amount of broader CFD knowledge, but I am new to Inventor CFD.

 

Thanks!

Luke

 

 

 

0 Likes
Accepted solutions (1)
603 Views
4 Replies
Replies (4)
Message 2 of 5

maciej.jaskiernik
Autodesk
Autodesk

Hi @luke_allen9FV6X!

I've checked the topic with our Autodesk CFD development team python master.

Unfortunately there is no way to import numpy into python editor in Autodesk CFD.

If this topic is important for you, please create a thread in "CFD Ideas" forum.

Best regards,

Maciej 

 

0 Likes
Message 3 of 5

luke_allen9FV6X
Explorer
Explorer

Thanks for the reply, however the tone of your message makes it clear that you did not understand my use-case. I have no intention of doing any serious computations with Python. Python is excellent for writing "glue code" that handles the high-level workflow, e.g., automating repetitive tasks. That's why the API exists. 

0 Likes
Message 4 of 5

luke_allen9FV6X
Explorer
Explorer
Accepted solution

Thank you for the reply. I was eventually able to figure out a solution.

 

The issue was that I had installed numpy using the conda package manager, instead of pip. This created conflicts in the C extensions that numpy uses. Once I figured that out, I recreated my external python environment using only pip and successfully ran my entire workflow. I only needed to add sys.path.append("path/to/external/python/lib/site-packages") to my script before importing numpy (or other external libraries). This is exactly what I tried before my original post, but with numpy (etc.) installed from a different source.

0 Likes
Message 5 of 5

matthieu.griveletAH26V
Enthusiast
Enthusiast

Oh, So you actually could use the API for something ?

I tried several times but after a few exchanges with the support, it appears that the API was not finished and there is no further development planned...

Many functions from the documentation are not implemented and it's almost impossible to automate the export of results.

 

If I'm not too intrusive, what did you use the API for ?

0 Likes