I want to use mu own package. This is the procedure I take:

1) In Mathematica notebook I put the following code taken from code

AddTwo::usage = 
"AddTwo[\!\(\*StyleBox[\"a\", \"TI\"]\), \!\(\*StyleBox[\"b\", \"TI\
\"]\)] returns \!\(\*StyleBox[\"a\", \"TI\"]\)+\!\(\*StyleBox[\"b\", \
DotTwo::usage = 
"DotTwo[\!\(\*StyleBox[\"a\", \"TI\"]\), \!\(\*StyleBox[\"b\", \"TI\
\"]\)] returns \!\(\*StyleBox[\"a\", \"TI\"]\)*\!\(\*StyleBox[\"b\", \
AddTwo::argnum = 
"AddTwo was called with `1` arguments. It expected 2.";
DotTwo::argnum = 
"DotTwo was called with `1` arguments. It expected 2.";


AddTwo[a_, b_] := a + b
AddTwo[args___] := (Message[AddTwo::argnum, Length[{args}]]; $Failed)
DotTwo[a_, b_] := a*b
DotTwo[args___] := (Message[DotTwo::argnum, Length[{args}]]; $Failed)


2) Go to SaveAs SOPackage.m

3) Put the file in $UserBaseDirectory/Applications

4) load the package with << SOPackage`

The problem is that nothing is loaded (I checked with Names["SOPackage`*"]). How to do this right?

I am using Mathematica 10.1 on Linux.

  • $\begingroup$ See (31302) $\endgroup$
    – ilian
    Aug 29, 2015 at 18:17
  • $\begingroup$ You quoted Names["SOPackages`*"], while it should've been Names["SOPackage`*"]. Could it be just a simple typo? $\endgroup$ Aug 29, 2015 at 18:17
  • $\begingroup$ yes a typo. Sorry $\endgroup$
    – WoofDoggy
    Aug 29, 2015 at 18:18
  • $\begingroup$ So, does the correct command give you the function names all right? $\endgroup$ Aug 29, 2015 at 18:18
  • $\begingroup$ Unfortunately not :( empty. $\endgroup$
    – WoofDoggy
    Aug 29, 2015 at 18:20

1 Answer 1


All cells in a notebook saved as a .m file which is intended to be loaded with Get or Needs must be initialization cells.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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