I am facing a problem in loading the package. My code is working in Mathematica but after deploying it into CDF, it is unable to load the package and shows error.

The code was not even working in Mathematica when I evaluated it for the first time but when I evaluated it one more time it worked.

I got help from this stackexchange question

And now it is working in Notebook but not in CDF, after relaunching the Mathematica Kernel.


As I understand, three things are needed:

  • Explicitly list the contexts of the functions that are in the package. For example, if you are using the function f in package test call it test`f[] instead of just f[].

  • Call Needs on the package inside the initialization option for the Manipulate that makes up your CDF. I would recommend calling needs with the syntax that gives the full file path to the package. For example: Initialization->{Needs["Plambda","filepathhere"]}`

  • Place the package inside the installation directory for CDFPlayer under AddOns\Applications. For example under windows:

    C:\Program Files\Wolfram Research\Wolfram CDF

My honest recommendation is that you create a simple example package and CDF and try to get this to work before getting a real world example working. The example will be much easier to debug and think about.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.