Build AirSDK example Python Virtual Environment

I’m unable to build AirSDK example Hello Done example.

I’m using clean instuall of Ubuntu 22.04.2 LTS
I tried to create a virtual environment with the os native python 3.10 and encounter this error.per the Olympe reference and got this error.

Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/staging/usr/lib/python/site-packages/parrot/missions/samples/hello/airsdk/messages_msghub.py <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/mission_ui/protobuf/parrot/missions/samples/hello/airsdk/messages.proto
x64 C++: airsdk-hello-protobuf-mission_ui <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-protobuf-mission_ui/gen/parrot/missions/samples/hello/airsdk/messages.pb.cc
Traceback (most recent call last):
  File "/home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/staging-host/usr/lib/msghub/msghub_gen_cpp.py", line 38, in <module>
    from google.protobuf.compiler import plugin_pb2 as plugin
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/compiler/plugin_pb2.py", line 9, in <module>
    from google.protobuf import reflection as _reflection
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/reflection.py", line 51, in <module>
    from google.protobuf import message_factory
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/message_factory.py", line 49, in <module>
    from google.protobuf.internal import python_message as message_impl
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/internal/python_message.py", line 69, in <module>
    from google.protobuf.internal import well_known_types
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/internal/well_known_types.py", line 788, in <module>
    collections.MutableMapping.register(Struct)
AttributeError: module 'collections' has no attribute 'MutableMapping'
Traceback (most recent call last):

I pulled in another version python 3.8.10 and rebuilt my virtual environment and I still get the same error. I even pointed the virtual environment to the local version of python.

virtualenv my_venv --python=/home/uavsim/.localpython/bin/python3

(my_venv) uavsim@uavsim-Precision-7560:~/AirSDKcode/airsdk-samples/hello$ python --version
Python 3.8.10

Note the paths still points to 3.10 even in this new virtual enviroment whichBTW is symbolically linked to 3.8 in the airsdk library.

".../lib/python3.10/.."

I’ve read that something the packaging of the protobufs got moved for python releases around python3.9 which is why this package cannot be imported or found which is what the error is alluding to.
Please let me know what I’m doing wrong.

Full compile output:

(my_venv) uavsim@uavsim-Precision-7560:~/AirSDKcode/airsdk-samples/hello$ airsdk build --simulator
[I] Starting task 'all'
[I] Starting task 'build'
[I] Starting task 'alchemy' with args: all final
[I] In '/opt/parrot-airsdk/parrot-airsdk-base': ALCHEMY_TARGET_CONFIG_DIR="/home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/product/hello/pc/config" ALCHEMY_TARGET_OUT="/home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc" ALCHEMY_TARGET_PRODUCT="hello" ALCHEMY_TARGET_PRODUCT_VARIANT="pc" ALCHEMY_TARGET_SCAN_ADD_DIRS=" /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/services/cv-service /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/cv_service /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/guidance /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/mission_ui /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/fsup /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/guidance/hello" ALCHEMY_TARGET_SCAN_PRUNE_DIRS=" /opt/parrot-airsdk/parrot-airsdk-base" ALCHEMY_USE_COLORS="1" ALCHEMY_WORKSPACE_DIR="/opt/parrot-airsdk/parrot-airsdk-base" PARROT_BUILD_PROP_GROUP="drones" PARROT_BUILD_PROP_PRODUCT="hello" PARROT_BUILD_PROP_PROJECT="airsdk-missions" PARROT_BUILD_PROP_UID="0.0.0" PARROT_BUILD_PROP_VARIANT="pc" PARROT_BUILD_PROP_VERSION="0.0.0" /opt/parrot-airsdk/parrot-airsdk-base/build/alchemy/scripts/alchemake -j 16 all final
Copying /opt/parrot-airsdk/parrot-airsdk-base/sdk/pc/host/ to /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/staging-host
----------------------------------------------------------------------
+ ALCHEMY_WORKSPACE_DIR = /opt/parrot-airsdk/parrot-airsdk-base
+ TARGET_PRODUCT = hello
+ TARGET_PRODUCT_VARIANT = pc
+ TARGET_OS = linux
+ TARGET_OS_FLAVOUR = native-chroot
+ TARGET_LIBC = native
+ TARGET_ARCH = x64
+ TARGET_CPU = 
+ TARGET_OUT = /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc
+ TARGET_CONFIG_DIR = /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/product/hello/pc/config
+ TARGET_CC_PATH = /usr/bin/gcc
+ TARGET_CC_VERSION = 11
----------------------------------------------------------------------
Scanning /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/services/cv-service for makefiles...
Scanning /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/cv_service for makefiles...
Scanning /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/guidance for makefiles...
Scanning /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/mission_ui for makefiles...
Scanning /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/fsup for makefiles...
Scanning /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/guidance/hello for makefiles...
Found 9 makefiles
Found 95 modules
Computing modules dependencies...
Checking modules dependencies...
/opt/parrot-airsdk/parrot-airsdk-base/build/alchemy/main.mk:374: /opt/parrot-airsdk/parrot-airsdk-base/sdk/pc: module 'libflightplan-pb-helper' exports missing include '/opt/parrot-airsdk/parrot-airsdk-base/sdk/pc/usr/include/libflightplan-pb-helper/gen'
/opt/parrot-airsdk/parrot-airsdk-base/build/alchemy/main.mk:374: /opt/parrot-airsdk/parrot-airsdk-base/sdk/pc: module 'pybind11' exports missing include '/opt/parrot-airsdk/parrot-airsdk-base/sdk/pc/usr/lib/python/dist-packages/pybind11/include'
Generating rules...
Processing rules...
Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/staging/usr/lib/python/site-packages/samples/hello/guidance/messages_msghub.py <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/guidance/protobuf/samples/hello/guidance/messages.proto
Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-msghub-c-cv_service/gen/samples/hello/cv_service/messages.msghub-c.c <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/cv_service/protobuf/samples/hello/cv_service/messages.proto
Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-msghub-c-guidance/gen/samples/hello/guidance/messages.msghub-c.c <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/guidance/protobuf/samples/hello/guidance/messages.proto
Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-msghub-c-mission_ui/gen/parrot/missions/samples/hello/airsdk/messages.msghub-c.c <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/mission_ui/protobuf/parrot/missions/samples/hello/airsdk/messages.proto
Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-msghub-cv_service/gen/samples/hello/cv_service/messages.msghub.cc <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/cv_service/protobuf/samples/hello/cv_service/messages.proto
Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-msghub-guidance/gen/samples/hello/guidance/messages.msghub.cc <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/guidance/protobuf/samples/hello/guidance/messages.proto
x64 C++: airsdk-hello-protobuf-cv_service <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-protobuf-cv_service/gen/samples/hello/cv_service/messages.pb.cc
Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-msghub-mission_ui/gen/parrot/missions/samples/hello/airsdk/messages.msghub.cc <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/mission_ui/protobuf/parrot/missions/samples/hello/airsdk/messages.proto
x64 C++: airsdk-hello-protobuf-guidance <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-protobuf-guidance/gen/samples/hello/guidance/messages.pb.cc
Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/staging/usr/lib/python/site-packages/samples/hello/cv_service/messages_msghub.py <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/cv_service/protobuf/samples/hello/cv_service/messages.proto
Generating: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/staging/usr/lib/python/site-packages/parrot/missions/samples/hello/airsdk/messages_msghub.py <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/packages/msghub/mission_ui/protobuf/parrot/missions/samples/hello/airsdk/messages.proto
x64 C++: airsdk-hello-protobuf-mission_ui <= /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-protobuf-mission_ui/gen/parrot/missions/samples/hello/airsdk/messages.pb.cc
Traceback (most recent call last):
  File "/home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/staging-host/usr/lib/msghub/msghub_gen_c.py", line 37, in <module>
    from google.protobuf.compiler import plugin_pb2 as plugin
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/compiler/plugin_pb2.py", line 9, in <module>
    from google.protobuf import reflection as _reflection
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/reflection.py", line 51, in <module>
    from google.protobuf import message_factory
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/message_factory.py", line 49, in <module>
    from google.protobuf.internal import python_message as message_impl
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/internal/python_message.py", line 69, in <module>
    from google.protobuf.internal import well_known_types
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/internal/well_known_types.py", line 788, in <module>
    collections.MutableMapping.register(Struct)
AttributeError: module 'collections' has no attribute 'MutableMapping'
Traceback (most recent call last):
  File "/home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/staging-host/usr/lib/msghub/msghub_gen_cpp.py", line 38, in <module>
    from google.protobuf.compiler import plugin_pb2 as plugin
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/compiler/plugin_pb2.py", line 9, in <module>
    from google.protobuf import reflection as _reflection
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/reflection.py", line 51, in <module>
    from google.protobuf import message_factory
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/message_factory.py", line 49, in <module>
    from google.protobuf.internal import python_message as message_impl
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/internal/python_message.py", line 69, in <module>
    from google.protobuf.internal import well_known_types
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/internal/well_known_types.py", line 788, in <module>
    collections.MutableMapping.register(Struct)
AttributeError: module 'collections' has no attribute 'MutableMapping'
Traceback (most recent call last):
  File "/home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/staging-host/usr/lib/msghub/msghub_gen_python.py", line 36, in <module>
    from google.protobuf.compiler import plugin_pb2 as plugin
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/compiler/plugin_pb2.py", line 9, in <module>
    from google.protobuf import reflection as _reflection
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/reflection.py", line 51, in <module>
    from google.protobuf import message_factory
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/message_factory.py", line 49, in <module>
    from google.protobuf.internal import python_message as message_impl
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/internal/python_message.py", line 69, in <module>
    from google.protobuf.internal import well_known_types
  File "/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/internal/well_known_types.py", line 788, in <module>
    collections.MutableMapping.register(Struct)
AttributeError: module 'collections' has no attribute 'MutableMapping'
--custom_out: protoc-gen-custom: Plugin failed with status code 1.
make: *** [/opt/parrot-airsdk/parrot-airsdk-base/build/alchemy/main.mk:320: /home/uavsim/AirSDKcode/airsdk-samples/hello/.airsdk/out/hello-pc/build/airsdk-hello-msghub-c-cv_service/_home_uavsim_AirSDKcode_airsdk-samples_hello_.airsdk_packages_msghub_cv_service_protobuf_samples_hello_cv_service_messages.proto.c.finished] Error 1

MAKE ERROR DETECTED
[E] Command failed (returncode=254)

I tried installing protobuf in the virtual machine environment

(my_venv) uavsim@uavsim-Precision-7560:~/AirSDKcode/airsdk-samples/hello$ python3 -m pip install protobuf

I had to add libssl to my older python instance in order to do this.

Same results…

I ended adjusting the parrot-airsdk by fixing the reference to collections as suggested by this site.

Find import collections and replace it with import collections.abc as collections in the following files:

I only had to modify

/opt/parrot-airsdk/parrot-airsdk-cli/lib/python3.10/site-packages/google/protobuf/internal/well_known_types.py

I don’t believe this is the best long term solution so hopefully there a more correct way to setup the venv.