1
$\begingroup$

This is a followup question to packages will not load.

I can get SamplePackage to load by doing <<SamplePackage.m or <<SamplePackage' but I cannot get TMPClasses.m package to load, which I took from 'The Mathematica Programmer' by Maeder. Initially, TMPClasses.m was in ...Applications/myPackages/ and wouldn't load. I had myPackages in the search path. Since SamplePackage would work I tried to make the situation as symmetric as possible by renaming myPackages folder to TMPClasses, the same name as the package. The SamplePackage.m file is in a folder named SamplePackage. Except for the contents of the files themselves and the order the folders are placed in the search path I cannot think of any other asymmetries between the two situations. Any ideas on why this won't work? See the images below to see what I tried as well as the file structure.This is what I tried

enter image description here

As you can see, both files can be found: enter image description here

As was suggested to me in the previous question I posted, for both packages I tried making a Kernel directory in the same directory as the .m file. In the Kernel directory I placed an init.m file with the contents Get["SamplePackage'SamplePackage'"] or Get["TMPClasses'TMPClasses'"]. After doing this, SamplePackage still loaded properly, and I was able to access the functions, and TMPClasses still would not load.

$\endgroup$
  • 1
    $\begingroup$ Keep things simple. Packages should be placed in $UserBaseDirectory/Applications, and not in a subdirectory of $UserBaseDirectory/Applications (at least not until you have a full understanding of what that does). Do not create any Kernel directories. That is for package authors who create multi-file packages. You should not do that when you simply want to install a package. $\endgroup$ – Szabolcs Jun 23 at 7:01
  • $\begingroup$ Get["somefile"] will evaluate the contents of the file returned by FindFile["somefile"]. This is what loading means. If Classes is not defined, then most like the file did not have a definition for Classes within. Double-check the contents of the exact file returned by FindFile. $\endgroup$ – Szabolcs Jun 23 at 7:06
  • $\begingroup$ There are some anomalies in what you show in the screenshot: $Path appears to be the first evaluation, yet it contains paths that should not be there by default (such as your SamplePackage directory). Did you add something to your init.m? Do not do this: it is not necessary and every modification you make (but do not mention) makes it harder for us to debug your problem. $\endgroup$ – Szabolcs Jun 23 at 7:09
  • $\begingroup$ Keep things simple, and try to give a complete and concise description of the problem. Be sure to include a minimal example where you mention every detail. Last time you neglected to mention that you put your files in subdirectories and not on the $Path, which ended up wasting a lot of time. $\endgroup$ – Szabolcs Jun 23 at 7:10
  • $\begingroup$ Finally, $Packages is irrelevant for this problem. You do not need to bother with it. But please: explain the problem in a clear, structured way, and provide a complete minimal example: sscce.org Use the structure I suggested here. $\endgroup$ – Szabolcs Jun 23 at 7:11
0
$\begingroup$

Copying the code for TMPClasses and pasting it in a new file made it work for some reason

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ This does not answer the question. It is just another symptom for diagnosing your problem, not a solution. Check the permissions on the package file and see if it is readable. $\endgroup$ – Szabolcs Jun 23 at 7:02

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.