我正在为代码创建日志文件,但是我遇到了以下错误:
[Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] import mainLCF [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] File "/home/ai/Desktop/home/ubuntu/LCF/GA-LCF/mainLCF.py", line 10, in [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] logging.basicConfig(filename='genetic.log',level=logging.DEBUG,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/logging/__init__.py", line 1528, in basicConfig [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] hdlr = FileHandler(filename, mode) [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/logging/__init__.py", line 901, in __init__ [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] StreamHandler.__init__(self, self._open()) [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/logging/__init__.py", line 924, in _open [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] stream = open(self.baseFilename, self.mode) [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] IOError: [Errno 13] Permission denied: '/genetic.log'
我已经检查了我想要创建日志的特定文件夹中的权限,但仍然出现错误。
我的代码如下(名称为mainLCF.py):
import logging import sys logging.basicConfig(filename='genetic.log',level=logging.DEBUG,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') logging.debug("starting of Genetic Algorithm")
sys.path.append("/home/ai/Desktop/home/ubuntu/LCF/ws_code")
import blackboard from pyevolve import * def eval_func(chromosome): # 这里有一些函数
我的系统文件结构如下:
/ home ai Desktop home ubuntu LCF ws_code GA-LCF blackboard.py main-LCF.py
[Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] import mainLCF [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] File "/home/ai/Desktop/home/ubuntu/LCF/GA-LCF/mainLCF.py", line 10, in [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] logging.basicConfig(filename='genetic.log',level=logging.DEBUG,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/logging/__init__.py", line 1528, in basicConfig [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] hdlr = FileHandler(filename, mode) [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/logging/__init__.py", line 901, in __init__ [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] StreamHandler.__init__(self, self._open()) [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/logging/__init__.py", line 924, in _open [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] stream = open(self.baseFilename, self.mode) [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] IOError: [Errno 13] Permission denied: '/genetic.log'
我已经检查了我想要创建日志的特定文件夹中的权限,但仍然出现错误。
我的代码如下(名称为mainLCF.py):
import logging import sys logging.basicConfig(filename='genetic.log',level=logging.DEBUG,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') logging.debug("starting of Genetic Algorithm")
sys.path.append("/home/ai/Desktop/home/ubuntu/LCF/ws_code")
import blackboard from pyevolve import * def eval_func(chromosome): # 这里有一些函数
我的系统文件结构如下:
/ home ai Desktop home ubuntu LCF ws_code GA-LCF blackboard.py main-LCF.py
我正在从 ws_code 中的另一个函数 lcf.py 中调用 mainLCF.py。
'/genetic.log'
,该文件位于文件系统的根目录,而不是您检查权限的任何文件夹中。 - Wooble