简体   繁体   English

如何在 Octave 中永久加载包?

[英]How to load packages in Octave permanently?

I am using Octave on Window vista.我在 Window vista 上使用 Octave。 I am using 4 package in my code.我在我的代码中使用了 4 个包。 But every time I restart octave, I have to load manually from command line, 'pkg load ...' Is there a way to load them permanently so that whenever Octave is started it finds them in its path.但是每次我重新启动八度时,我都必须从命令行手动加载,'pkg load ...' 有没有办法永久加载它们,以便每当八度启动时它都会在其路径中找到它们。

When Octave starts, it runs ~/.octaverc .当 Octave 启动时,它运行~/.octaverc If you want Octave to automatically load a package, simply add a pkg load pkg-name command to it.如果您希望 Octave 自动加载包,只需向其添加pkg load pkg-name命令即可。 If the files does not exist, create it.如果文件不存在,请创建它。

If you do this, remember that other people may not have Octave configured to load packages at startup.如果您这样做,请记住其他人可能没有将 Octave 配置为在启动时加载包。 Therefore, if you write code for others, remember that your programs still need to load the packages they require.因此,如果您为他人编写代码,请记住您的程序仍然需要加载它们需要的包。

Do not use pkg install -auto ... or pkg rebuild -auto .. because that will stop working on the next Octave release.不要使用pkg install -auto ...pkg rebuild -auto ..因为这将停止下一音阶发行工作。

I got the answer.我得到了答案。 It can be set at the time of package installation.可以在安装包时设置。 install with following command pkg install -auto [package name] It will be load every time octave is started.使用以下命令安装 pkg install -auto [package name] 每次八度启动时都会加载它。

create a file named "startup.m" with this content:使用以下内容创建一个名为“startup.m”的文件:

packs = pkg('list');
for jj = 1:numel(packs),
  pkg('load', packs{jj}.name);
end

in the directories "octave-home/share/octave/version/m/startup/octaverc" and "octave-home/share/octave/site/m/startup/octaverc".在目录“octave-home/share/octave/version/m/startup/octaverc”和“octave-home/share/octave/site/m/startup/octaverc”中。 ( https://www.gnu.org/software/octave/doc/v4.2.1/Startup-Files.html ) So it loads all packages at startup. ( https://www.gnu.org/software/octave/doc/v4.2.1/Startup-Files.html ) 所以它在启动时加载所有包。

Install the packages on your working directory.在您的工作目录中安装软件包。 Then add "pkg load pkg_name" command to octave-1.1~\\share\\octave\\site\\m\\startup\\octaverc.然后将“pkg load pkg_name”命令添加到octave-1.1~\\share\\octave\\site\\m\\startup\\octaverc。 It will load the package every time.它每次都会加载包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM