Search code examples
pythonscikits

Python commpy library error: no module named 'filters'


I have recently installed a library using this code:

pip install scikit-commpy

Moreover, I downloaded the tar.gz file from this site: https://pypi.org/project/scikit-commpy/#files and launch the setup.py file, but when I do this on python to check the installation:

import commpy

It gives me the following error:

File "C:\ProgramData\Anaconda3\lib\site-packages\commpy\__init__.py", line 17, in <module>
    from filters import *

ModuleNotFoundError: No module named 'filters'

Solution

  • So it looks like the __init__.py file in that directory has broken imports somehow. I was able to fix it in vim by changing the import to:

    init.py

    from .filters import *
    from .modulation import *
    from .impairments import *
    from .sequences import *
    

    I'm not sure how that will impact other functionalities in the module, but that does allow me to run

    import commpy
    
    

    with no errors.

    NOTE

    It appears this behavior is further down in the module as well, so if you were to attempt

    from commpy import channelcoding
    

    it will raise similar exceptions. So you will have to do more surgery on the module in ./commpy/channelcoding/__init__.py:

    from .convcode import Trellis, conv_encode, viterbi_decode
    from .interleavers import *
    from .turbo import turbo_encode, map_decode, turbo_decode
    from .ldpc import ldpc_decode
    from .gfields import *
    from .algcode import *
    

    Upon further inspection, the syntax of this library is python2