[SOLVED] TP-link add on fails with python import error "Not found gateway_addon"

Hello all, I’m new here so I hope to learn about the IOT project and build my own gateway on a Raspi3. I’m not in any rush, but then again I always feel rushed and unexpected errors like this can get me flustered. So I’m posting this and I’ll check replies later, I may even figure it out in that time and I will certainly update if I do! I haven’t found this specific problem before but again my google skills are more suited to windows errors it seems. Very new to linux, raspi, etc.

I’m trying to load the TP_Link add on but in my terminal it simply displays the error in the title over and over until i stop the add-on.

I found the github page for the add-on and it has me perform a few steps since I build this iot environment by following the official instructions I thought it would be the fix, but sadly I ran into a problem when I tried to execute the following:

sudo pip3 install nnpy
sudo pip3 install git+https://github.com/mozilla-iot/gateway-addon-python.git

Which throws and error as follows:

sudo pip3 install nnpy
Collecting nnpy
Using cached https://files.pythonhosted.org/packages/23/20/490a767ad65f43e42d67766462336b8fee73fc34456ae1d15551f466332c/nnpy-1.4.2.tar.gz
Complete output from command python setup.py egg_info:
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
 #include <ffi.h>
                 ^
compilation terminated.
Traceback (most recent call last):
  File "/usr/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/usr/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/usr/lib/python3.5/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/usr/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 161, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 147, in call_command
    self.run_command(cmdname)
  File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/install_lib.py", line 24, in run
    self.build()
  File "/usr/lib/python3.5/distutils/command/install_lib.py", line 109, in build
    self.run_command('build_ext')
  File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 75, in run
    _build_ext.run(self)
  File "/usr/lib/python3.5/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/usr/lib/python3.5/distutils/command/build_ext.py", line 448, in build_extensions
    self._build_extensions_serial()
  File "/usr/lib/python3.5/distutils/command/build_ext.py", line 473, in _build_extensions_serial
    self.build_extension(ext)
  File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 196, in build_extension
    _build_ext.build_extension(self, ext)
  File "/usr/lib/python3.5/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/usr/lib/python3.5/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/usr/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 157, in save_modules
    yield saved
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 255, in run_setup
    DirectorySandbox(setup_dir).run(runner)
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 285, in run
    return func()
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 253, in runner
    _execfile(setup_script, ns)
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 47, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-wtru4orv/cffi-1.11.5/setup.py", line 240, in <module>
  File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
    raise SystemExit("error: " + str(msg))
SystemExit: error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1131, in run_setup
    run_setup(setup_script, args)
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 258, in run_setup
    raise
  File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 169, in save_modules
    saved_exc.resume()
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 144, in resume
    six.reraise(type, exc, self._tb)
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 157, in save_modules
    yield saved
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 255, in run_setup
    DirectorySandbox(setup_dir).run(runner)
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 285, in run
    return func()
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 253, in runner
    _execfile(setup_script, ns)
  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 47, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-wtru4orv/cffi-1.11.5/setup.py", line 240, in <module>
  File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
    raise SystemExit("error: " + str(msg))
SystemExit: error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-ewshbgze/nnpy/setup.py", line 28, in <module>
    install_requires=['cffi'],
  File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 317, in __init__
    self.fetch_build_eggs(attrs['setup_requires'])
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 372, in fetch_build_eggs
    replace_conflicting=True,
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 846, in resolve
    dist = best[req.key] = env.best_match(req, ws, installer)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1118, in best_match
    return self.obtain(req, installer)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1130, in obtain
    return installer(requirement)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 440, in fetch_build_egg
    return cmd.easy_install(req)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 699, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 725, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 906, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1145, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1133, in run_setup
    raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ewshbgze/nnpy/

I’m really not sure what to do with that. Ideas? I’m not using the official image because I want to use my raspi for other things potentially and I installed this on top of a fresh up-to-date Raspbian.

Edit. I suspect I may be missing something called libffi

According to https://raspberrypi.stackexchange.com/questions/37281/cant-install-flask-bcrypt-libffi-is-missing

Edit 2 Thank you poster for confirming :smiley: That solved the errors with the pip3 install

Edit 3: Fixed. I took a few minutes to d othe dishes and it cleared my head. REMEMBER TO TAKE A BREAK PEOPLE!

You should be able to fix your issue by doing the following in a terminal on the Raspberry Pi:

sudo apt update
sudo apt install libffi-dev libnanomsg4 libnanomsg-dev
1 Like