Python Plugin: numpy + scipy - Cinema4D R20



  • Hello, how can I install and import numpy and scipy in python27 environment?
    Is there a portable way to ship the modules with the plugin?

    Sorry if there's already an answer, but I can find only legacy and unclear posts on this topic with mostly broken links. Is there a drive with precompiled packages?

    How can I support also windows?

    Thanks in advance!



  • While zipit is almost all corrected, I just wanted to point:
    NumPy rely on some CPython dll, that need to be compatible with the python executable for more information see Building NumPy for Cinema 4D on Windows.
    However, that's being said, with c4dpy (in R20 it was not included in the regular c4d installation you need to download it from Downloads Page. Then normally you can just run the usual pip -install NumPy it should work (take care to check NumPy have a tendency to break quite often).

    For SciPy you can also install it via pip, but Cinema 4D doesn't officially support any Qt porting, so while it's possible to make it work you may encounter some weird behavior (like closing SciPy windows may close Cinema 4D, SciPy windows can't be docked, etc)

    For the moment there is no easy way to share these modules with your plugin, the easiest is probably to have a script that will run c4dpy and install the needed dependencies.

    Hope this answers your question,
    Cheers,
    Maxime.



  • Hi,

    1. numpy has no external dependencies in its vanilla package and can be "drag and drop" installed when absolutely necessary.
    2. scipy on the other hand is an ever growing pile of dependencies and therefore needs pip to be installed properly.
    3. You will have to install pip manually on Cinema's Python. There are multiple threads here in the forum on how to do that.
    4. Although I would not hold my breath for things working perfectly, since c4dpy is not just a rebranded vanilla CPython, but is also missing other stuff.
    5. You also would have to jump through all these hoops on the machine of a user. Which is not very practical.
    6. I would just run a vanilla CPython interpreter of your choice with the packages of your choice and establish a sever-client interface between this CPython and Cinema's c4dpy to do what you want.
    7. This will obviously come with quite a hefty performance penalty, but is IMHO the only reliable way to use said packages in a "not just dicking around locally"-scenario.

    Cheers,
    zipit



  • While zipit is almost all corrected, I just wanted to point:
    NumPy rely on some CPython dll, that need to be compatible with the python executable for more information see Building NumPy for Cinema 4D on Windows.
    However, that's being said, with c4dpy (in R20 it was not included in the regular c4d installation you need to download it from Downloads Page. Then normally you can just run the usual pip -install NumPy it should work (take care to check NumPy have a tendency to break quite often).

    For SciPy you can also install it via pip, but Cinema 4D doesn't officially support any Qt porting, so while it's possible to make it work you may encounter some weird behavior (like closing SciPy windows may close Cinema 4D, SciPy windows can't be docked, etc)

    For the moment there is no easy way to share these modules with your plugin, the easiest is probably to have a script that will run c4dpy and install the needed dependencies.

    Hope this answers your question,
    Cheers,
    Maxime.



  • Thanks zipit and m_adam!

    BTW I just need scientific functions, not Qt UI



  • I do not use c4dpy with older version than R23.
    I simply unpack wheels or compile, for example - scipy



  • Hi,

    without further feedback, we will consider this thread as solved by tomorrow and flag it accordingly.

    Cheers,
    Ferdinand