ConvE icon indicating copy to clipboard operation
ConvE copied to clipboard

AttributeError: 'Logger' object has no attribute 'f'

Open cheungdaven opened this issue 6 years ago • 10 comments

Traceback (most recent call last): File "main.py", line 13, in from evaluation import ranking_and_hits File "D:\Codes\ConvE\evaluation.py", line 5, in from spodernet.utils.global_config import Config File "d:\codes\conve\src\spodernet\spodernet\utils\global_config.py", line 4, in log = Logger('global_config.py.txt') File "d:\codes\conve\src\spodernet\spodernet\utils\logger.py", line 60, in init path = join(get_logger_path(), file_name) File "d:\codes\conve\src\spodernet\spodernet\utils\logger.py", line 18, in get_logger_path return join(get_home_path(), '.data', 'log_files') File "d:\codes\conve\src\spodernet\spodernet\utils\logger.py", line 15, in get_home_path return os.environ['HOME'] File "C:\Users\shuaizhang\AppData\Local\Programs\Python\Python36\lib\os.py", line 669, in getitem raise KeyError(key) from None KeyError: 'HOME' Exception ignored in: <bound method Logger.del of <spodernet.utils.logger.Logger object at 0x0000029BBC69C080>> Traceback (most recent call last): File "d:\codes\conve\src\spodernet\spodernet\utils\logger.py", line 71, in del self.f.close() AttributeError: 'Logger' object has no attribute 'f'

cheungdaven avatar Mar 06 '19 01:03 cheungdaven

hello,
how did you fix the problem?
Hope to hear from you soon.

Bryan2Chow avatar Dec 09 '19 06:12 Bryan2Chow

I would like to know about it as well

rajathpatel23 avatar May 19 '20 03:05 rajathpatel23

This seems to be a Windows related problem. There is no HOME variable in the path that points to the folder where the data is stored. This is just a poor implementation on my side. You can try to replace the path. Otherwise, I might have a look at this after a deadline that I am having in two weeks to fix this.

TimDettmers avatar May 19 '20 19:05 TimDettmers

Yes, I did sense it to be Windows problem, will check it out by changing the path

rajathpatel23 avatar May 19 '20 19:05 rajathpatel23

i used 'windir' instead of 'HOME' but still didn't work, if any one interested to try

saleems11 avatar Jun 04 '20 19:06 saleems11

change 'HOME' to 'HOMEPATH', then it can run in windows

xuxiaoman7 avatar Oct 18 '20 02:10 xuxiaoman7

the format used here to save the evaluation file is problematic for windows , in addition to changing 'HOME' TO 'HOMEPATH', you should change the name of the evaluation log file.

Eldadkro avatar Dec 29 '20 12:12 Eldadkro

the format used here to save the evaluation file is problematic for windows , in addition to changing 'HOME' TO 'HOMEPATH', you should change the name of the evaluation log file.

Hello, may I ask you that what does " change the name of the evaluation log file." mean???

Gosline01 avatar Jan 04 '21 12:01 Gosline01

sorry it is the first time I am responding to something in github so maybe I wasn't clear , in file evaluation.py in line 9 when you call the init for logger you need to give it a name to save the log file as, however the way it was first written with the date inside causes issues inside windows with the os system calls.

Eldadkro avatar Jan 04 '21 13:01 Eldadkro

Traceback (most recent call last): File "D:/研究生文献/知识图谱/KGC/Embedding-based模型/SACN/SACN-master/main.py", line 13, in from evaluation import ranking_and_hits File "D:\研究生文献\知识图谱\KGC\Embedding-based模型\SACN\SACN-master\evaluation.py", line 13, in log = Logger('evaluation{0}.py.txt'.format(datetime.datetime.now())) File "D:\研究生文献\知识图谱\KGC\Embedding-based模型\SACN\SACN-master\src\spodernet\spodernet\utils\logger.py", line 64, in init self.f = open(path, write_type) OSError: [Errno 22] Invalid argument: '\Users\10443\.data\log_files\evaluation2022-08-11 11:34:28.182847.py.txt' Exception ignored in: <function Logger.del at 0x000001F7DA2CA950> Traceback (most recent call last): File "D:\研究生文献\知识图谱\KGC\Embedding-based模型\SACN\SACN-master\src\spodernet\spodernet\utils\logger.py", line 71, in del self.f.close() AttributeError: 'Logger' object has no attribute 'f'

Process finished with exit code 1

Excuse me, what is this question

yifenggithub avatar Aug 11 '22 03:08 yifenggithub