eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.

Home Page:http://mraa.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python mrra fails with error "NameError: name '_uint8Array__mraa' is not defined" [solved]

g-vidal opened this issue · comments

I compile successfully mraa on rpi3 rpi3P+ rpi4 under buster (and bullseye)
mra-XXX commands work properly but when I try to use mraa with python3 it fails at import :

raspife3P-€ : python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mraa
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib/python3.7/dist-packages/mraa.py", line 101, in <module>
   class uint8Array(_object):
 File "/usr/lib/python3.7/dist-packages/mraa.py", line 114, in uint8Array
   __swig_destroy__ = __mraa.delete_uint8Array
NameError: name '_uint8Array__mraa' is not defined

I have tried to compile

  • with g++-7 and g++-8
  • with swig 3.0.12 and 4.1.0
  • mraa version 1.9.0 and 2.2
    with always the same error in python execution. I used the same method for years until now and everything was working like a charm.... Does anybody have a hint or an idea on what is wrong?
    Thanks all

After many tests i tried to retrieve an old CMakeLists.txt and restart the compilation with it.
MRAA works fine no more errors on loading
There must be something wrong in that file. I'll try to find out but I need some sleep....
After some sleep and performance recovery here is the explanation :

I tried to get rid of the informative(?) messages during cmake concerning cmake_policy and without testing it I put both policies for CMP0078 and CMP0086 to NEW which is wrong with the following configuration no error messages during cmake and mrra works :

cmake_minimum_required (VERSION 2.8.11)
project (mraa C)

FIND_PACKAGE (Threads REQUIRED)

if (CMAKE_VERSION VERSION_LESS "3.1")
  if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
    set (CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
  endif ()
else ()
  set (CMAKE_C_STANDARD 99)
  cmake_policy(SET CMP0078 OLD)
  cmake_policy(SET CMP0086 NEW)  
endif ()

If those modifications can be admitted as generic I can make the PR
This issue can be closed thanks

commented

how to generate the file “mraa.py”

when run my python3 file,it will return erro on "import mraa"