ccpem/mrcfile

AttributeError: module 'mrcfile' has no attribute 'open

kimdn opened this issue · 2 comments

kimdn commented

I installed mrcfile by pip.

import mrcfile
went through well.

However,
with mrcfile.open('EMD-3197.map') as mrc:
resulted in

"AttributeError: module 'mrcfile' has no attribute 'open"

print (mrcfile.validate('EMD-3197.map'))
resulted in
AttributeError: module 'mrcfile' has no attribute 'validate'
as well.

/Users/kimd999/Library/Python/2.7/bin
that has
f2py, mrcfile-header, mrcfile-validate are in my PATH.

Can I know why I can't run mrcfile?
I can't run mrcfile both in my macOS (10.14.6) and Linux (centos).

Installation by
conda install --channel conda-forge mrcfile
also didn't help the situation.

kimdn commented

Sorry for my embarrassing question,

it looks like when I specified
import mrcfile
it tried to read my local mrcfile.py instead.

That's why it can't find open and validate attributes.

When I changed mrcfile.py to test.py and ran again, no error happened.

Now,

import mrcfile
print dir(mrcfile)
print mrcfile.__file__

results in

['builtins', 'doc', 'file', 'name', 'package', 'path', 'version', 'absolute_import', 'bzip2mrcfile', 'constants', 'division', 'dtypes', 'future_mrcfile', 'gzipmrcfile', 'load_functions', 'mmap', 'mrcfile', 'mrcinterpreter', 'mrcmemmap', 'mrcobject', 'new', 'new_mmap', 'open', 'open_async', 'print_function', 'unicode_literals', 'utils', 'validate', 'validator', 'version']
/Users/kimd999/Library/Python/2.7/lib/python/site-packages/mrcfile/init.pyc

Also
command line of

mrcfile-validate EMD-3197.map

results in

File does not declare MRC format version 20140: nversion = 0

when EMD-3197.map came from

https://github.com/ccpem/mrcfile/blob/master/tests/test_data/EMD-3197.map

or from

https://www.ebi.ac.uk/pdbe/entry/emdb/EMD-3197