0

I am trying to use a python deep learning module keras-audio to train from audio files (python 3.8.6, MacOS 10.14.6). However, after installing that module and trying to run an example I get the following error

Traceback (most recent call last):
  File "demo/cifar10_train.py", line 1, in <module>
    from keras_audio.library.cifar10 import Cifar10AudioClassifier
  File "/Users/user/keras-audio/keras-audio/keras_audio/library/cifar10.py", line 2, in <module>
    from lru import LRU
ModuleNotFoundError: No module named 'lru'

so I tried to install that package with

pip install lru

which created the following error:

Collecting lru
  Using cached lru-0.1.tar.gz (1.1 kB)
    ERROR: Command errored out with exit status 1:
     command: /Users/users/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/0g/wwq2q6nn35n8vmrwhw5qfk601zlkw_/T/pip-install-tohqsyc0/lru_e04682eaa31f4d3291305bac811979b4/setup.py'"'"'; __file__='"'"'/private/var/folders/0g/wwq2q6nn35n8vmrwhw5qfk601zlkw_/T/pip-install-tohqsyc0/lru_e04682eaa31f4d3291305bac811979b4/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/0g/wwq2q6nn35n8vmrwhw5qfk601zlkw_/T/pip-pip-egg-info-kv5i7tfq
         cwd: /private/var/folders/0g/wwq2q6nn35n8vmrwhw5qfk601zlkw_/T/pip-install-tohqsyc0/lru_e04682eaa31f4d3291305bac811979b4/
    Complete output (8 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/0g/wwq2q6nn35n8vmrwhw5qfk601zlkw_/T/pip-install-tohqsyc0/lru_e04682eaa31f4d3291305bac811979b4/setup.py", line 2, in <module>
        from lru import __version__ as version
      File "/private/var/folders/0g/wwq2q6nn35n8vmrwhw5qfk601zlkw_/T/pip-install-tohqsyc0/lru_e04682eaa31f4d3291305bac811979b4/lru.py", line 18
        raise KeyError, key
                      ^
    SyntaxError: invalid syntax
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Any idea how to fix this error?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Alex
  • 41,580
  • 88
  • 260
  • 469
  • `raise KeyError, key` is Python 2 syntax, so it looks like this package hasn't been upgraded to work with Python 3. – snakecharmerb Jan 24 '21 at 09:06
  • As @snakecharmerb, pointed this is python2 syntax. But in any case, I don't think they use that package. Looking at the [requirements.txt](https://github.com/chen0040/keras-audio/blob/c34c30695169e0f274c0f3d175dba2b4c9dc301a/requirements.txt#L9) it is [lru_dict package](https://pypi.org/project/lru-dict/) being used, but not mentioned in [setup.py](https://github.com/chen0040/keras-audio/blob/master/setup.py) – buran Jan 24 '21 at 09:09
  • 1
    Yes thanks, looks like that. But then I get another error. I guess this is a dead end. There is no useful machine learning package. I need to write one! – Alex Jan 24 '21 at 09:14
  • You may want to edit your post, then, because as written, the answer is `pip install lru-dict` – OneCricketeer Jan 24 '21 at 10:56
  • Try `pip install libpython3.8-dev` and then install `pip install lru-dict` – Yashashvi Jul 29 '21 at 14:42

1 Answers1

0

Was getting the same issue, after installing pip install libpython3.8-dev it was fixed. For different version of python install package accordingly, i.e. pip install libpython3.6-dev

For different operation system, refer to this answer

Yashashvi
  • 340
  • 3
  • 12