![](/img/trans.png)
[英]Unable to deploy python script , upon closing terminal script stops running
[英]python script stops running on terminal after 1 minute
我的 python 腳本遇到問題。 我在我的機器上使用 Ubuntu 作為第二個操作系統,我已經編寫了 python 代碼到 output 關於某些蛋白質的不同信息。 在給我輸出第一個蛋白質之后,它在第二個蛋白質的過程中間減慢了很多,並且在某些時候它不會再響應了。 當我鍵入 control+c 時,我收到以下消息:
Traceback (most recent call last):
File "testPerf.py", line 185, in <module>
uniqueDict(args.input,args.output)
File "testPerf.py", line 73, in uniqueDict
keyName = '%s_%s' %(hmm[i],cassetteId[i])
File "/home/t/anaconda3/envs/crispr-env/lib/python3.7/site-packages/pandas/core/series.py",
line 1071, in __getitem__
result = self.index.get_value(self, key)
File "/home/t/anaconda3/envs/crispr-env/lib/python3.7/site-packages/pandas/core/indexes>>/base.py", line 4708, in get_value
s = getattr(series, "_values", series)
File "/home/t/anaconda3/envs/crispr-env/lib/python3.7/site-packages/pandas/core/series.py", line 562, in _values
它停止時的代碼部分如下:
with open(crisprOutputFile, "r") as file1:
data = pd.read_csv(file1)
hmm = data.HMM
cassetteId = data.cassette_id
list1 = data.predicted_label
i = 0
while i < len(hmm):
predictedL = list1[i][7:20]
predictedL = predictedL.replace( ')','')
predictedL = predictedL.replace( ']','')
predictedL = predictedL.replace( "'","")
predictedL = predictedL.replace( ',','')
keyName = '%s_%s' %(hmm[i],cassetteId[i])
if keyName not in dict1:
dict1[keyName] = predictedL
i+=1
這是一段代碼,從一個名為 KrisprOutputFile 的文件中讀取內容,並嘗試 output 字典中的一些數據,這很容易......之后,這個字典與其他一些字典結合,給出了 output 字典,其中包含有關蛋白質的數據。 請幫忙。
在給定的代碼片段中,如果在dict1
中找到keyName
,則i
不會遞增。 如果i
保持不變,則當前迭代將與上一次迭代相同,因此它將成為無限循環。
如果您實際上打算在每次迭代時更新i
(這更有意義),請像這樣降低i+=1
的集成級別
with open(crisprOutputFile, "r") as file1:
data = pd.read_csv(file1)
hmm = data.HMM
cassetteId = data.cassette_id
list1 = data.predicted_label
i = 0
while i < len(hmm):
predictedL = list1[i][7:20]
predictedL = predictedL.replace( ')','')
predictedL = predictedL.replace( ']','')
predictedL = predictedL.replace( "'","")
predictedL = predictedL.replace( ',','')
keyName = '%s_%s' %(hmm[i],cassetteId[i])
if keyName not in dict1:
dict1[keyName] = predictedL
i+=1
正如評論中@run-out 所建議的那樣,我建議您使用for
循環。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.