0
$\begingroup$

My operating system is Ubuntu. I add some new .m file to /usr/local/Wolfram/Mathematica/9.0/AddOns/Packages/ and then call for it in Mathematica, but failed with the message Get::noopen: "Cannot open !(\"Qdensity.m\").".

What should I do to make it work?

$\endgroup$
  • $\begingroup$ you probably have no read access? Maybe it is better to put the file in $UserBaseDirectory $\endgroup$ – Rolf Mertig Aug 15 '13 at 21:50
  • $\begingroup$ @RolfMertig What system on your computer? I can make it work in Windows but not in Ubuntu. And I do not know what is $UserBaseDirectory. You may take your Mathematica for example. Thanks a lot! $\endgroup$ – Eden Harder Aug 17 '13 at 2:48
  • $\begingroup$ In[1]:= $UserBaseDirectory Out[1]= /home/rolfm/.Mathematica Please read the documentation $\endgroup$ – Rolf Mertig Aug 17 '13 at 9:33
  • $\begingroup$ Thanks! But in which folder? Applications? $\endgroup$ – Eden Harder Aug 17 '13 at 9:45
  • 1
    $\begingroup$ Yes, or Autoload. $\endgroup$ – Rolf Mertig Aug 17 '13 at 9:51
2
$\begingroup$

Usually Mathematica under Linux is installed as root. Therefore normal users do not have wite permission to /usr/local/Wolfram/Mathematica/9.0/AddOns/ . This is why you see that message you mentioned. While in principle you could do something like chown -R eden:eden /usr/local/Wolfram , this is neither encouraged nor advisable. Instead, as mentioned in the documentation of Mathematca, you put user-packages into the Applications or Autoload directory inside either $UserBaseDirectory or $BaseDirectory.

However all you really need to do is to put a package somewhere in a directory which is on $Path. I.e. just like MemberQ[$Path, FileNameJoin[{$UserBaseDirectory, "Applications"}]] gives True, so should MemberQ[$Path,"/opt/mpackdir"], which you can easily achieve by something like If[!MemberQ[$Path, "/opt/mydir"],AppendTo[$Path,"/opt/mydir"].

So all is really easy and clear.

$\endgroup$

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.