2011-05-04 8 views
1

우리 프로그램이 Windows XP에서 ActivePerl 2.6을 사용하여 실행될 때 다음과 같은 오류가 발생합니다 (Linux에서도 제대로 실행되지만). 무슨 일이 일어나고 있는지에 대한 아이디어가 있습니까? 이것은 모듈의 버그 또는 코드의 문제점입니까?Windows에서 python 과학 모듈을 사용하여 속성 오류가 발생했습니다.

오류 로그 :

 File "C:\Python26\lib\site-packages\Scientific\IO\PDB.py", line 1163, in __ini 
    t__ 
     self.parseFile(PDBFile(file_or_filename)) 
     File "C:\Python26\lib\site-packages\Scientific\IO\PDB.py", line 1371, in parse 
    File 
     type, data = file.readLine() 
    File "C:\Python26\lib\site-packages\Scientific\IO\PDB.py", line 200, in readLi 
    ne 
     line = self.file.readline() 
    AttributeError: 'unicode' object has no attribute 'readline' 
    Exception AttributeError: "'unicode' object has no attribute 'close'" in <bound 
    method PDBFile.__del__ of <Scientific.IO.PDB.PDBFile instance at 0x00FD0440>> ig 
    nored 

UPDATE : 아래 조의 제안에 따라, 내가 대신 다음과 같은 오류 얻을 : 내가 추측하고있어

Traceback (most recent call last): 
    File "NewParseV1_00.py", line 47, in <module> 
    PromptUser() 
    File "NewParseV1_00.py", line 45, in PromptUser 
    parseGroupFile(grpfilepath, outputPPYfilepath, sorcePDBfilepath) 
    File "NewParseV1_00.py", line 39, in parseGroupFile 
    return GeneratePPY(LL,GRPNAME,SRCPDB,OUTPPY) 
    File "NewParseV1_00.py", line 10, in __init__ 
    self.PDBStruct = Scientific.IO.PDB.Structure(SRCPDB) 
    File "C:\Python26\lib\site-packages\Scientific\IO\PDB.py", line 1163, in __ini 
t__ 
    self.parseFile(PDBFile(file_or_filename)) 
    File "C:\Python26\lib\site-packages\Scientific\IO\PDB.py", line 161, in __init 
__ 
    if isinstance(file_or_filename, basestr): 
NameError: global name 'basestr' is not defined 
Exception AttributeError: "PDBFile instance has no attribute 'open'" in <bound m 
ethod PDBFile.__del__ of <Scientific.IO.PDB.PDBFile instance at 0x00FDB418>> ign 
ored 

답변

1

을하지만 Scientific.IO.PDB의 버그처럼 보이는 어디 다음과 같이하지 말고

if type(file_or_filename) == str: 
    file = open(file_or_filename) 
else: 
    file = file_or_filename 

:

if isinstance(file_or_filename, basestr): 
    ... 

어떤 이유로 든 Windows 측에서 유니 코드 파일 이름을 전달하고 Linux 측에서 원시 문자열을 전달하는 것으로 보입니다.

다시 말하지만, 나는 추측을하고 있습니다. 나는이 모듈이 여기 Scientific이라고 가정하고 있습니까? http://dirac.cnrs-orleans.fr/plone/software/scientificpython/ (나는 그것에 익숙하지 않다 ...)

편집 : 그래!

여기 Scientific.IO.PDB에서 관련 코드입니다 :

class PDBFile: 

    """ 
    X{PDB} file with access at the record level 

    The low-level file access is handled by the module 
    L{Scientific.IO.TextFile}, therefore compressed files and URLs 
    (for reading) can be used as well. 
    """ 

    def __init__(self, file_or_filename, mode = 'r', subformat = None): 
     """ 
     @param file_or_filename: the name of the PDB file, or a file object 
     @type file_or_filename: C{str} or C{file} 
     @param mode: the file access mode, 'r' (read) or 'w' (write) 
     @type mode: C{str} 
     @param subformat: indicates a specific dialect of the PDB format. 
          Subformats are defined in 
          L{Scientific.IO.PDBExportFilters}; they are used 
          only when writing. 
     @type subformat: C{str} or C{NoneType} 
     """ 
     if isinstance(file_or_filename, str): 
      self.file = TextFile(file_or_filename, mode) 
     else: 
      self.file = file_or_filename 
     <snip> 

그것은 isinstance(file_or_filename, basestr)isinstance(file_or_filename, str)을 변경하는 것만 큼 간단해야한다. 당신이 조에서 설명 된 바와 같이 Scientific.IO.PDB의 코드를 변경

0

작업 한 최종 수정 필요 ... 버그보고를 할 수 있습니다 : 라인 161에

을 변경 if isinstance(file_or_filename, str):-if isinstance(file_or_filename, basestring):

(Joe는 두 번째 인수는 basestr이어야한다고 말했지만 원래 질문에서 업데이트에 오류가 있습니다.)

관련 문제