我試圖從USB驅動器運行Python腳本時出現此錯誤。我已經將當前目錄中的所有文件複製到U盤上,Python腳本可以從另一臺Ubuntu機器上運行。OSError:[Errno 13]從USB驅動器執行python腳本時,權限被拒絕
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1545, in __call__
return self.func(*args)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 402, in button_press_event
FigureCanvasBase.button_press_event(self, x, y, num, dblclick=dblclick, guiEvent=event)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 1909, in button_press_event
self.callbacks.process(s, mouseevent)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/cbook.py", line 549, in process
proxy(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/cbook.py", line 416, in __call__
return mtd(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/widgets.py", line 434, in _update
self.set_val(val)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/widgets.py", line 448, in set_val
func(val)
File "/media/mghansar/MG/ktn/UQM_Prototype_V1.03_RD4.py", line 509, in update_slider1
updateval_slider1(self.mu_a1,self.sigma_a1)
File "/media/mghansar/MG/ktn/UQM_Prototype_V1.03_RD4.py", line 488, in updateval_slider1
getout1= self.surrogate_call(in5)
File "/media/mghansar/MG/ktn/UQM_Prototype_V1.03_RD4.py", line 431, in surrogate_call
process = Popen([binary_name, '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
從Ubuntu 16.10當前目錄執行程序時,它工作正常。
該腳本嘗試讀取可執行文件時,它會引發上述錯誤。下面是相關的代碼
def surrogate_call(self,inputs, binary_name='./ktn-sgp'):
'''
@param inputs pandas.DataFrame (one row per input point)
'''
from subprocess import Popen, PIPE
from StringIO import StringIO
# call the surrogate compiled from C code
process = Popen([binary_name, '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
(stdout_data, stderr_data) = process.communicate(inputs.to_csv(header=False, index=False))
exit_code = process.wait()
任何幫助將不勝感激。
您是否有權在驅動器上進行讀取和寫入? –
您是否檢查過USB上的Linux權限和文件組,它們與機器上的相同嗎?輸入'll' – cardamom
@Burhan哈立德,小豆蔻:所有者(我)有權讀取和寫入。 「組」和「其他」對文件和文件夾具有隻讀權限。目錄權限和USB之間的區別在於當前目錄中選中「允許執行文件作爲程序」選項,而未在USB驅動器中選中該選項。當我嘗試檢查該選項時,它不允許我。 –