nickabattista / IB2d

An easy to use immersed boundary method in 2D, with full implementations in MATLAB and Python that contains over 75 built-in examples, including multiple options for fiber-structure models and advection-diffusion, Boussinesq approximations, and/or artificial forcing.
GNU General Public License v3.0
167 stars 90 forks source link

failed to import shared library #10

Closed cubayang closed 5 years ago

cubayang commented 5 years ago

Hi Nick,

I am trying to generate shared library to use the C write method on Mac OS using:

python setup.py build_ext —-inplace

A write.so file can be generated, however, when I tried to import write in ipython, an error occurs:

snip20181205_10

I tried to find a solution online, but it seems a bit complicated. Have you ever met this problem before?

Thanks in advance, Yang

mountaindust commented 5 years ago

Hello Yang,

I can't reproduce the error on my mac, but doing some poking around on the interwebs it looks like this error may be caused by a Python version mismatch. It's likely that the setup.py being used when you compile is from your system Python that ships with mac, which is typically 2.x. Then you try to load this library with ipython, which starts from the 3.x Anaconda Python installation (because the system python does not include ipython) and an error is thrown. If this is in fact the case, the reason I could not reproduce the error is because I have appended my Anaconda directory to my path in my terminal bash profile, so when I type "python" into a terminal it looks there first instead of in the system python directory.

Try running python3 setup.py build_ext --inplace instead and let me know if it works.

cubayang commented 5 years ago

Hi Christopher,

Thanks a lot for your reply.

I tried running with python3 setup.py build_ext --inplace, it is still not working. As you have mentioned, I might have some setup issue of my anaconda, I will try to fix and see if it works.

mountaindust commented 5 years ago

I'm going to close this for now since I can't reproduce it. It could be that the system python is also 3.x, in which case you may need to explicitly specify the path to the Anaconda executable or prefix your bash path so you don't have to specify every time you are working in a terminal.