Python OSError:[Errno 2]没有这样的文件或目录 - Linux

时间:2014-01-10 16:06:39

标签: python linux bash

在我的Linux服务器上运行一个bash脚本运行一个名为'AoS'的游戏服务器(Ace of Spades)时,我收到以下错误:

Traceback (most recent call last):
  File "./run.py", line 70, in <module>
    SERVER_VERSION = '%s - rev %s' % (sys.platform, get_hg_rev())
  File "./run.py", line 55, in get_hg_rev
    stdout=subprocess.PIPE, stderr = subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

我可以看到它与第70行和第70行有关。 55,subprocess.py是问题所在。 我已经检查过/usr/lib/python2.7/subprocess.py中是否存在'subprocess.py'而且确实存在。

第70行的代码:

SERVER_VERSION = '%s - rev %s' % (sys.platform, get_hg_rev())

然后是第53-55行的代码:

pipe = subprocess.Popen(  #53
    ["hg", "log", "-l", "1", "--template", "{node}"], #54
    stdout=subprocess.PIPE, stderr = subprocess.PIPE) #55

任何人都可以看到上面的代码有什么问题吗?

第55行的错误所在的功能:

def get_hg_rev():
    import subprocess
    pipe = subprocess.Popen(
        ["hg", "log", "-l", "1", "--template", "{node}"],
        stdout=subprocess.PIPE, stderr = subprocess.PIPE) # Here
    ret = pipe.stdout.read()[:12]
    if not ret:
        return '?'
    return ret

然后是第70行错误所在的函数:

if frozen:
    path = os.path.dirname(unicode(sys.executable, sys.getfilesystemencoding()))
    sys.path.append(path)
    try:
        SERVER_VERSION = 'win32 bin - rev %s' % (open('version', 'rb').read())
    except IOError:
        SERVER_VERSION = 'win32 bin'
else:
    sys.path.append('..')
    SERVER_VERSION = '%s - rev %s' % (sys.platform, get_hg_rev()) # Here

进口:

import sys
import os
import json
import itertools
import random
import time
import shutil
import subprocess
from collections import deque

0 个答案:

没有答案