Nohup失败于Anaconda ipython [英] Nohup failing with Anaconda ipython

查看:270
本文介绍了Nohup失败于Anaconda ipython的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Anaconda IPython上使用"nohup"命令运行代码. 如果我在类似ipython的环境中运行它,我的代码可以正常运行(数小时)

I am trying to run a code using "nohup" command with Anaconda IPython. My code runs fine (for hours) if I run it inside ipython environment like;

irsacf00-debian:~/WISE_AP> ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %run WISE_PHOT_052918_MODULER_IRSACF.py

但是,当我尝试使用"nohup"运行相同的代码时,它会崩溃并显示以下错误消息(最后两行).这是从输出文件粘贴的副本.

However, when I try to run the same code using "nohup" it breaks down with the following error message (last 2 lines). This is copy pasted from output file.

[[0;31mOSError^[[0m: [Errno 5] Input/output error

In [2]: Do you really want to exit ([y]/n)?

我的nohup命令如下:

My nohup command looks like this;

irsacf00-debian:~/WISE_AP> nohup ipython <input_file> output_file &

我的输入文件如下:

%run /home/aprakash/WISE_AP/WISE_PHOT_052918_MODULER_IRSACF.py 

我不知道代码在哪里卡住了.感谢您的帮助!

I can't figure out where the code is getting stuck. Thanks for help!

最好, 阿比(Abhi)

Best, Abhi

推荐答案

无论何时启动Anaconda Environment,它都会粘在您的shell上,从而使ipython可用. (对于默认环境也是如此.) nohup的任务是从启动它的外壳中分离出一个进程.

Whenever an Anaconda Environment is started, it sticks to your shell, making ipython available. (This is also true for default environment.) nohup's task is to part a process from the shell you start it with.

执行以下操作:编写一个shell脚本,该脚本首先将conda绑定到其shell,然后使用ipython启动程序.请注意,conda并不支持所有shell,因此请使用bash.我的版本如下:

Do the following: Write a shell script, which first, binds conda to its shell, and then starts your program with ipython. Be aware, that conda does not support all shells, so use bash. My version looks like this:

#!/bin/bash
source /home/yOURuSERnAME/miniconda3/etc/profile.d/conda.sh
conda activate YourCondaEnvironment
ipython SomeProgramOfYours.py

(第一行强制使用必要的conda兼容外壳.第二行得到此处是与第三行结合使用的另一种方法.第四行是您亲自尝试给nohup的内容.

(First line enforces necessary conda-compatible shell. Second line I got from Stackoverflow myself :) Here is another way of doing this combining with third line. Fourth line is what you gave nohup in your own try.)

另存为Filename.sh,开始使用nohup:

Save as Filename.sh, start using nohup:

chmod +x Filename.sh
nohup ./Filename.sh &

这篇关于Nohup失败于Anaconda ipython的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆