I want to aoutoload a package at the beginning of a notebook. I set up my directory as written here

How to use the Autoload directory?

So, I have these files:

../Work/MyFile.nb

MyPack.m :

ClearAll["Progetto*"];

BeginPackage[ "Progetto"]

Prova::usage="Prova[]"

Begin["Private"];

Prova[]:=5+1;

End[]

EndPackage[]


init.m:

 Get["MyPackMyPack"]


In MyFile.nb, I would like use Prova[], but the output isn't 6 but is Prova[].

Where am I wrong? Am I missing something in init.m?

• Is Progetto  in $Packages after kernel launch? And in $ContextPath? – Kuba May 4 '17 at 8:41
• @Kuba Progetto isn't a file. Should I rename "Progetto" in "MyPack"? – Ale1794 May 4 '17 at 8:45
• I thought that "Progetto" was the name of the Package – Ale1794 May 4 '17 at 8:49
• $Packages contains context that were exported so if MyPack was loaded then Progetto  should be there. – Kuba May 4 '17 at 8:50 • @Kuba no, in$Packages there isn't Progetto – Ale1794 May 4 '17 at 8:56

I want to aoutoload a package at the beginning of a notebook.

In this case, create an initialization cell in the notebook, and load that package in that cell. Select the cell, and tick Cell menu -> Cell Properties -> Initialization Cell.

The Autoload directory I wrote about in the answer you are linking to is located in $UserBaseDirectory. There is only one* such directory, and it is used on kernel startup. It does not interact with notebooks in any way. * To be completely accurate, there are a few, but they all live in fixed locations, such as $UserBaseDirectory, $BaseDirectory, $InstallationDirectory/SystemFiles, etc.