Importing a model from SolidWorks: "DLL load failed while importing _core"

548 views
Skip to first unread message

Saagar Sanghavi

unread,
Jun 1, 2021, 12:02:55 PM6/1/21
to ProjectChrono
Hello ProjectChrono community,

I am having a bit of trouble importing a model from SolidWorks on my PC. I have successfully built the Chrono engine using CMake and Visual Studio using the setup instructions here: https://api.projectchrono.org/development/tutorial_install_chrono.html. And I have tested the demos, working. Now I am trying to import an assembly from SolidWorks, following instructions here: https://api.projectchrono.org/tutorial_chrono_solidworks_demo_engine.html. I have an assembly

I am able to do "Save as Python..." and save the model as a .py file called simple_crab.py. My folder contains simple_crab.py, run_test.py, _template_POV.pov, and /simple_crab_shapes 
I have inspected the python files that were created and they look fine.

Now I set Visualization=irrlicht and try to hit the "Run test" button, but nothing happens (a command window opens but then closes without doing anything). 

I am also trying to run it manually using `python .\run_test.py -- .\simple_crab.py` in an Anaconda Powershell prompt but that gives me the following error:

```
Traceback (most recent call last): File ".\run_test.py", line 24, in <module> import pychrono as chrono File "C:\Users\jages\anaconda3\envs\crab_research\lib\site-packages\pychrono\__init__.py", line 44, in <module> from .core import * File "C:\Users\jages\anaconda3\envs\crab_research\lib\site-packages\pychrono\core.py", line 13, in <module> from . import _core ImportError: DLL load failed while importing _core: A dynamic link library (DLL) initialization routine failed.
```

I have checked "..\Anaconda3\Lib\site-packages\pychrono" folder and found the _core.pyd , _postprocess.pyd etc. files inside it. 
Also have checked  "...\Anaconda3\Library\bin" folder and found the ChronoEngine.dll ChronoEngine_postprocess.dll etc. files inside it. 

Please advise, I am not sure what else I need to do to get these models to open in the Chrono engine. 

Best,
Saagar Sanghavi

PS. I have installed pychrono using anaconda as described here: https://api.projectchrono.org/development/pychrono_installation.html
I am using anaconda for just my user (not system) and working in an environment called "crab_research"

ben...@wisc.edu

unread,
Jun 3, 2021, 11:13:26 AM6/3/21
to ProjectChrono
Hi Saagar,
to me it looks like the issue is with the PyChroon installation. Can you run the demos?
Thanks,
Simone

Saagar Sanghavi

unread,
Jun 3, 2021, 11:56:01 AM6/3/21
to ben...@wisc.edu, ProjectChrono
I am able to run other Chrono demos (such as demo_FEA_brick.exe) but I can't seem to find any demos that use pychrono. I have installed pychrono using option A described here: https://api.projectchrono.org/development/pychrono_installation.html

I have tried both the main and projectchrono/label/develop options within a conda environment but neither are working.

--
You received this message because you are subscribed to a topic in the Google Groups "ProjectChrono" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/projectchrono/wPHK3rSe4LE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/fee44a51-d1c3-4ca6-855a-e8e89ed26461n%40googlegroups.com.

ben...@wisc.edu

unread,
Jun 4, 2021, 8:30:31 PM6/4/21
to ProjectChrono
All FEA demos and IRRLICHT demos use pychrono core. Just to be sure, can you run the bricks demo?
Thanks,
Simone

Saagar Sanghavi

unread,
Jun 4, 2021, 10:58:54 PM6/4/21
to ben...@wisc.edu, ProjectChrono
Yes, I can run that demo just fine! I think the problem might be with something else, do you have any idea what it could be?

Radu Serban

unread,
Jun 5, 2021, 4:48:39 AM6/5/21
to Saagar Sanghavi, SIMONE BENATTI, ProjectChrono

Saagar,

 

It sounds to me as you’re talking about running the compiled C++ demos (seeing how you mention demo_FEA_brick.exe).  The Python demos are provided only as sources.  Please see the notice at the top of https://api.projectchrono.org/tutorial_table_of_content_pychrono.html for where these are located, depending on how you installed PyChrono.

 

Can you run these *python* demos?

 

--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/CAB5heo8Fm6TgAN8wfHa%2BijSUVsjb1LJt1UaD-dtv5pjFmmK08Q%40mail.gmail.com.

 

Saagar Sanghavi

unread,
Jun 5, 2021, 11:34:15 PM6/5/21
to Radu Serban, SIMONE BENATTI, ProjectChrono
My bad, thanks for pointing that out. I can not run the demos, they give me the same error: 
```

Saagar Sanghavi

unread,
Jun 5, 2021, 11:34:56 PM6/5/21
to Radu Serban, SIMONE BENATTI, ProjectChrono
Error I get is 
```
line 44, in <module> from .core import * File "C:\Users\jages\anaconda3\envs\crab_research\lib\site-packages\pychrono\core.py", line 13, in <module> from . import _core ImportError: DLL load failed while importing _core: A dynamic link library (DLL) initialization routine failed.
```
Do you know what the problem is?

ben...@wisc.edu

unread,
Jun 6, 2021, 10:29:38 AM6/6/21
to ProjectChrono
I read you messages more thoroughly and I think I know what's going on and how to fix it. 
  •  option 1 :pychrono were built with CPU instructions that your CPU does not support (usually AVX2), just to make sure, check if your CPU does support AVX2.The good news is that since you are already building Chrono with CMake and VS, it's not a big deal to enable the pychrono module and build it yourself on your machine.
  • option 2: the python interpreter you are using does not correspond to the one you installed pychrono for, in this case, Anaconda "base" env. Speaking of which, installing packages in the base env is not recommended, you usually create a new virtual env and work there, so that if enythning goes wrong you can just delete the environment without messing up the whole Anaconda installation. 
Let me know if you can or not solve this issue!
Thanks,
Simone

Saagar Sanghavi

unread,
Jun 7, 2021, 12:50:39 AM6/7/21
to ben...@wisc.edu, ProjectChrono
You are right. I did some digging and it appears that AVX2 is not supported on my CPU. I guess I will have to try enabling pychrono when building from the source. 

ben...@wisc.edu

unread,
Jun 7, 2021, 11:45:37 AM6/7/21
to ProjectChrono
Also, reading more carefully it looks like you correctly did everything in a virtual env, so that was definitely not the issue. To buid pychrono locally following these ( Project Chrono: Install the PYTHON module) instructions. 
Also, note that you can use your Anaconda env Python interpreter to build pychrono, just set the lib, include and exe in "C:\Users\jages\anaconda3\envs\crab_research"

Thanks,
Simone

Saagar Sanghavi

unread,
Jun 14, 2021, 4:58:54 PM6/14/21
to ben...@wisc.edu, ProjectChrono
I have tried building pychrono using CMake to generate the solution which I then build with Visual Studio. However, somewhere in the output of Visual Studio I get 
``` 
>LINK : fatal error LNK1104: cannot open file '..\..\..\lib\Debug\ChronoEngine_pyparser.lib' 
>Done building project "demo_PY_import_solidworks.vcxproj" -- FAILED.
```
There are a few other errors in the build. Other demos (non-python) seem to build fine though and I can run them as normal. 

There are a few other things that don't happen according to the instructions. According to "Building Instructions" on this page, I am supposed to be seeing "CH_PYTHONDIR" and "SWIG_DIR" and "SWIG_EXECUTABLE" as fields in CMake, but I don't see them anywhere. 

And once I am done building it is not there, I am not able to import the modules I want to use in python. 

What am I supposed to do...this is really frustrating.

For reference, the full output of CMake.

ben...@wisc.edu

unread,
Jun 15, 2021, 10:23:43 AM6/15/21
to ProjectChrono
Hi,
thanks for posting the cmake and VS output, this is really helpful!
The error is "LINK : fatal error LNK1104: cannot open file 'python37_d.lib'".
You can fix it as explained in the pychrono building instructions or build in release.
Thanks,
Simone

Saagar Sanghavi

unread,
Jun 20, 2021, 7:23:14 PM6/20/21
to ben...@wisc.edu, ProjectChrono
I see, thanks for letting me know. I followed the instructions at the bottom of this page: https://api.projectchrono.org/development/module_python_installation.html 
And so I changed the lines in pyconfig.h file as instructed.  Now I am able to build the modules successfully in Visual Studio.

However, I now encounter this other issue. When I try to run
> python3 .\demo_CH_coords.py 
in the powershell command prompt, I get an ImportError: cannot import name '_core' from partially initialized module 'pychrono' (most likely due to a circular import).

The full traceback is this

First tutorial for PyChrono: vectors, matrices etc.

Traceback (most recent call last):
  File "C:\Users\jages\Desktop\Research\chrono\src\demos\python\core\demo_CH_coords.py", line 15, in <module>
    import pychrono as chrono
  File "C:\Users\jages\Desktop\Research\chrono_build\bin\Debug\pychrono\__init__.py", line 44, in <module>
    from .core import *
  File "C:\Users\jages\Desktop\Research\chrono_build\bin\Debug\pychrono\core.py", line 13, in <module>
    from . import _core
ImportError: cannot import name '_core' from partially initialized module 'pychrono' (most likely due to a circular import) (C:\Users\jages\Desktop\Research\chrono_build\bin\Debug\pychrono\__init_.py)

I am not sure what else is wrong. How do I identify and fix a circular import if that is the case? 

Saagar

Saagar Sanghavi

unread,
Jun 20, 2021, 7:45:24 PM6/20/21
to ben...@wisc.edu, ProjectChrono
Nevermind, I think I got it to work, my issue was that I was using the wrong version of python


Saagar Sanghavi

unread,
Jun 20, 2021, 7:49:12 PM6/20/21
to ben...@wisc.edu, ProjectChrono
This is awesome! Thank you so much for all the help :) 

Saagar 
Reply all
Reply to author
Forward
0 new messages