在 Ubuntu 16.04 中从任意目录运行程序

在 Ubuntu 16.04 中从任意目录运行程序

我在电脑上安装了天文学软件 CASA,我想只需casa在 Ubuntu 终端中输入即可从任何目录运行它。我应该进行哪些更改才能实现这一点?我尝试了以下方法:

sudo ln -s ./home/alcrespe/Desktop/casa-prerelease-4.7.0-22/bin/casa ./usr/bin/casa

...但它不起作用。我不是 Ubuntu 专家,我该如何解决这个问题?正如上一行所示,到目前为止,我只能在以下位置访问程序 CASA:

./home/alcrespe/Desktop/casa-prerelease-4.7.0-22/bin/casa

答案1

根据我的发现,您需要解决两个问题:

  1. 正确做法:

    • 尽管链接上说的是,但您显然没有steps correctly像我一样遵循并已使用命令成功运行它。casacasapy
    • 解决方法请按照步骤操作逐字

      • sudo mkdir /usr/local/bin/CASA
      • sudo mv casapy-30.0.9860-001-64b.tar.gz /usr/local/bin/CASA
      • cd /usr/local/bin/CASA
      • sudo tar zxvf casapy-30.0.9860-001-64b.tar.gz
      • 将其添加到您的~/.bashrc文件中,然后使用以下命令获取它source ~/.bashrc
        • export PATH=$PATH:/usr/local/bin/CASA/casapy-30.0.9860-001-64b/bin
      • 测试一下:casa
      • 输出:

         george@george-ubuntu-server:~$ casa
        
         =========================================
         The start-up time of CASA may vary
         depending on whether the shared libraries
         are cached or not.
         =========================================
        
        CASA Version 5.0.0-101
        Compiled on: Thu 2017/01/05 04:33:33 UTC
        Activating service name='org.gnome.GConf'
        Successfully activated service 'org.gnome.GConf'
        Activating service name='org.gtk.vfs.Daemon'
        Successfully activated service 'org.gtk.vfs.Daemon'
        PYVER        -  2.7
        AIPS_DIR     -  /usr/local/bin/CASA/casa-stable-5.0.101
        SCRIPT_REPOS -  /usr/local/bin/CASA/casa-stable-
        5.0.101/linux/lib/python2.7/regressions/
        --------------------------------------------------------------------------------
        ls: cannot access '/usr/local/bin/CASA/casa-stable-5.0.101/linux/lib/python2.7/regressions/': No such file or directory
        --------------------------------------------------------------------------------
        ___________________________________________________________________
        For help use the following commands:
        tasklist               - Task list organized by category
        taskhelp               - One line summary of available tasks
        help taskname          - Full help for task
        toolhelp               - One line summary of available tools
        help par.parametername - Full help for parameter name
        ___________________________________________________________________
        ------------------------------------------------------------------------------------------
        
        {'dirs': {'xml': '/usr/local/bin/CASA/casa-stable-5.0.101/xml',
        
        'pipeline': None, 'python': '/usr/local/bin/CASA/casa-stable-5.0.101/lib/python2.7', 'data': '/usr/local/bin/CASA/casa-stable-5.0.101/data',
        'recipes': '/usr/local/bin/CASA/casa-stable-5.0.101/lib/python2.7/recipes', 
        'rc': '/home/george/.casa', 'root': '/usr/local/bin/CASA/casa-stable-5.0.101'}, 
        'files': {'logfile': '/home/george/casa-20170425-095553.log'},
        'source': {'url': 'https://svn.cv.nrao.edu/svn/casa/trunk', 'revision': '39214'}, 
        'state': {'unwritable': set([]), 'startup': True, 'init_version': 0}, 
        'helpers': {'info': None, 'viewer': 'casaviewer', 'crashPoster': '/usr/local/bin/CASA/casa-stable-5.0.101/bin/CrashReportPoster', 'dbus': '/usr/local/bin/CASA/casa-stable-5.0.101/lib/casa/bin/dbus-daemon', 'logger': 'casalogger', 'ipcontroller': '/usr/local/bin/CASA/casa-stable-5.0.101/lib/casa/bin/ipcontroller', 'ipengine': '/usr/local/bin/CASA/casa-stable-5.0.101/lib/casa/bin/ipengine'}, 
        'build': {'version': '5.0.0-101', 'number': '39214', 'time': 'Thu 2017/01/05 04:33:33 UTC'}, 'flags': {'/usr/local/bin/CASA/casa-stable-5.0.101/lib/python2.7/casapy.py': ''}}
         ------------------------------------------------------------------------------------------
         Activating auto-logging. Current session state plus future input saved.
         Filename       : ipython-20170425-095554.log
         Mode           : backup
         Output logging : False
         Raw input log  : False
         Timestamping   : False
         State          : active
         *** Loading ATNF ASAP Package...
         *** ... ASAP (rev#3110) import complete ***
        
         CASA <2>:    
        
  2. 库问题。最新版本适用于 Ubuntu Xenial,而你安装的版本可能不适用于你的 Ubuntu 版本,正如我在尝试安装你的版本时发现的那样4.*。因此,请与您的导师联系以获取进一步的帮助。

重要的提示:

您可能希望将其安装在虚拟设备上,因为我注意到您的版本坚持创建一个具有 id 的用户,1001而不管该 id 的所有者是谁。在我的例子中,该用户koko被设为目录的组所有者/usr/local/bin/CASA/*。授予文件夹的权限:

drwxr-xr-x 11  12998   1001      4096 Jan  5 06:09 casa-stable-5.0.101/

更改casapy-30.0.9860-001-64b为您下载的或解压后显示的名称

来源:

https://casaguides.nrao.edu/index.php/Installing_CASA

相关内容