Search code examples
python-3.xmdfasammdf

How to fix 'import asammdf' error in Python 3


I am trying to read some MDF files, so that I am planning to use asammdf package in Python 3.

I have installed latest version asammdf 5.6.0 in my anaconda environment in Windows 10 by using the command conda install -c conda-forge asammdf (as mentioned in the asammdf documentation). Every time I am running below command in python 3 from asammdf import MDF shows me errors.

from asammdf import MDF

I expect that library should get loaded but the actual errors are:

Traceback (most recent call last):

  File "<ipython-input-4-7f55c56e4067>", line 1, in <module>
    from asammdf import MDF

  File "C:\Users\AppData\Local\conda\conda\envs\machinelearning1\lib\site-packages\asammdf\__init__.py", line 17, in <module>
    from .blocks.mdf_v4 import MDF4

  File "C:\Users\AppData\Local\conda\conda\envs\machinelearning1\lib\site-packages\canmatrix\__init__.py", line 6, in <module>
    __version__ = canmatrix._version.get_versions()['version']

AttributeError: module 'canmatrix' has no attribute '_version'

Solution

  • This sounds like either a module install issue, or a conflicting install issue. This can happen when:

    1. You have the same module installed in multiple different places.
    2. You have multiple modules installed and two (2) or more rely on different versions of the same sub-module.

    Try the following:

    1. Start up a new Python environment.
    2. Isolate this environment as much as possible from all other environments (don't share modules, executables, .dlls where possible)
    3. Make sure the environment has ONLY the base Python package installed, no non-built in libraries or modules.
    4. Install the desired package, and test the import.
    5. If this fixes your import issue, you'll have to install the other modules you need one-by-one, testing that imports still work after each.