Using Version 9 on OS X, I've run into some problems with creating packages and accessing them. I've done the following:
- wrote all the function definitions in a notebook and tested that they all worked;
- created a package of the definitions.
- used
Install
to place the package in theFileNameJoin[{$UserBaseDirectory, "Applications"}]
directory;
For good measure I rebooted my computer and restarted Mathematica.
Attempting to load the package gives me nothing, so I simplified everything to see if I'd still have a problem. I made a very simple package:
BeginPackage["testPackage`"]
f::usage = "f[x] returns 2x"
Begin["`Private`"]
f[x_] := 2 x
End[ ]
EndPackage[ ]
I saved and installed it as I described above. Still nothing.
<< testPackage`
Names["testPackage`*"]
{}
I have also tried each of the following:
Get["testPackage`"] (* Doesn't appear to do anything or get any response from Mma *)
Get[FileNameJoin[{$UserBaseDirectory, "Applications", "testPackage`"}]]
$Failed
Needs["testPackage`"]
Needs::nocont: Context testPackage` was not created when Needs was evaluated. >>
Nothing works.
You can see the package installed in the ...Mathematica/Applications directory:
I followed (or at least thought I followed) the recommendations in How to install packages?
I thought doing so would place the package in a path known to the front end.
What have I missed?
$Path
? TryGet["testPackage.m", Path -> FileNameJoin[{$UserBaseDirectory, "Applications"}]]
. $\endgroup$FileNameJoin[{$UserBaseDirectory, "Applications"}]
. $\endgroup$Get[FileNameJoin[{$UserBaseDirectory, "Applications", "testPackage.m"}]]
work? Note that I changedtestPackage`
totestPackage.m
. $\endgroup$$UserBaseDirectory
, i.e. choose "Install for this user only", correct? I repeated the exact steps you describe (as far as I can tell), and it works correctly here. The question is what we did differently. $\endgroup$