DCASE-REPO / dcase_util

A collection of utilities for Detection and Classification of Acoustic Scenes and Events
https://dcase-repo.github.io/dcase_util/
MIT License
127 stars 33 forks source link

An error occurred when I loaded metadata, where is opening a file #1

Closed dby124 closed 6 years ago

dby124 commented 6 years ago

Traceback (most recent call last): File "D:/py_code/firstpython/venv/first_python/test_file.py", line 25, in db.initialize() File "D:\learn_program\Python27\lib\site-packages\dcase_util\datasets\datasets.py", line 566, in initialize self.load() File "D:\learn_program\Python27\lib\site-packages\dcase_util\datasets\datasets.py", line 408, in load self.load_meta() File "D:\learn_program\Python27\lib\site-packages\dcase_util\datasets\datasets.py", line 421, in load_meta self.meta_container.load() File "D:\learn_program\Python27\lib\site-packages\dcase_util\containers\metadata.py", line 899, in load with open(self.filename, 'rtU') as f: ValueError: Invalid mode ('rbt')

dby124 commented 6 years ago

I have change "with open(self.filename, 'rtU') as f:" to "with open(self.filename, 'rt') as f:"

toni-heittola commented 6 years ago

I suspect this error is related to universal newline mode which was deprecated in Python 3.X. However, based on your path you seem to be using Python 2.7?

Commit 6ec24e9114a54ee894dc8c8f8043b5fb87679a87 should make behaviour more robust across different versions of Python.

dby124 commented 6 years ago

Yes, I am using Python 2.7. Maybe Python 2.7 also don't support universal newline mode.

toni-heittola commented 6 years ago

Code was refactored to use io.open method instead inbuilt open in the commit 642f9aa04c329c007b7728358a4bb40ee75fe562 to get more robust behaviour across different Python versions.