Message Boards Message Boards

0
|
259 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Needs[] returns error: Context "MyPackage" was not created when Needs was evaluated

Posted 15 days ago

Needs[] returns: Context "MyPackage" was not created when Needs was evaluated.

I have added the path to the package file and checked that the path is actually correct and present.

The package looks like this:

BeginPackage["MyPackage`"]

.........

Begin["`Private`"]

<Function definitions> 

End[]

EndPackage[]

Any idea?

POSTED BY: Odd Ivar Haugen
4 Replies
Posted 14 days ago

Best would be if you could attach the .wl file of the package (or a simplified or skeleton version of it) . Then it is easier to help you troubleshoot.

POSTED BY: Hans Milton

Yes, I tried "Get" and also included the path in the call (both for "Needs" and for "Get"), just in case. Moreover, I also tried to copy the .wl file to a folder already present in "Path." Still, the same problem.

POSTED BY: Odd Ivar Haugen
Posted 14 days ago

Just to check, that your code for loading it definitely has a backquote on the end? As in <<MyPackage` or otherwise Needs[MyPackage`]`. It's worth trying both, and also with the path done in different ways as mentioned. If not, I'll try and replicate the problem in a minute.

POSTED BY: T Vine
Posted 14 days ago

Have you tried using a get (<< "/Users/documentation/Desktop/MyPackage.wl") statement instead? I believe get parses the directories differently which may be it. Or perhaps try and use the full path to your file if you're not already (e.g. C:/...). The actual package file looks fine though. Maybe if the former don't work/you've already tried them, you could share the code that's loading the package? Thanks :).

POSTED BY: T Vine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract