Can't run script in Olympe

Hey.
I would like to control my drone, so I have installed ubuntu and followed a guide for Olympe.

Everything went good, I made a script called takeoff.py. I did the “setup your shell environment” and " Create a simulated drone" part. But when I run:

(olympe-python3) $ python ./takeoff.py"

I get a ImportError, telling me that indent from textwrap can not import.

Then I have tried to run:

$ python3 ./takeoff.py"

But same problem, just not with “textwrap” but with “future”.

Do anyone know what I can do?

1 Like

Hi,

There is currently multiple new dependencies issues that have been reported this week. The most important is a regression in the olympe postinst script with virtualenv 20.0 that has just been released.

If you look carefully at the postinst script log you should see that the script fails to install the olympe Pyhton virtual environment.

We may have to make a bugfix release for this issue just before the next 1.2.0 GSDK release that is currently in preparation.

In the meantime, here is a patch and a fixed version of the postinst script for virtualenv 20.0.1

diff --git a/linux/env/postinst b/linux/env/postinst
index e5a1c61..3d75366 100755
--- a/linux/env/postinst
+++ b/linux/env/postinst
@@ -65,9 +65,7 @@ PYTHON=${PYTHON_TMPENV_DIR}/bin/python3
 env -i PATH=/usr/bin:/bin ${PYTHON} -EsS "${GET_PIP}" --prefix "${PYTHON_TMPENV_DIR}" --no-warn-script-location virtualenv --ignore-installed
 
 # Now that we have this new python env, create our definitive virtualenvs
-if [ ! -e "${PYTHON_ENV_DIR}/py3/bin/python" ]; then
-  PYTHONUSERBASE="${PYTHON_TMPENV_DIR}" ${PYTHON} -m virtualenv -p ${PYTHON} ${PYTHON_ENV_DIR}/py3
-fi
+PYTHONUSERBASE="${PYTHON_TMPENV_DIR}" ${PYTHON} -m virtualenv --copies -p ${PYTHON} ${PYTHON_ENV_DIR}/py3
 PYTHON=/usr/bin/python3
 rm -rf "${BOOTSTRAP_DIR}"
#!/bin/bash
# This script install olympe dependencies
#
# Usage:
# bash postinst

set -e

SCRIPT_PATH="`readlink -f "$0"`"
ENV_DIR="`dirname "$SCRIPT_PATH"`"
COMMON_DIR="`dirname "$ENV_DIR"`"
ARSDK_DIR="`dirname "$COMMON_DIR"`"
PRODUCT_DIR="`dirname "$ARSDK_DIR"`"
ROOT_DIR="`dirname "$PRODUCT_DIR"`"
MODULES_DIR="${ROOT_DIR}/packages"
PYTHON_ENV_DIR="${OLYMPE_PYTHON_ENV_DIR:-${ROOT_DIR}/.python}"

# Check if we need to sudo things
if [ "$(id -u)" != "0" ]
then
  SUDO="sudo"
  echo "This script might prompt you for your sudo password."
else
  SUDO=""
fi

# Install system packages with apt
${SUDO} apt-get update || true # who doesn't have invalid/broken apt sources

# Install python
${SUDO} apt-get -y install python3 python3-dev python3-pip wget

# olympe-deps build dependencies
${SUDO} /usr/bin/python3 -m pip install clang
CLANG_VERSION=$(/usr/bin/python3 -m pip show clang |grep '^Version' |cut -d' ' -f2 |cut -c1-3)
${SUDO} apt-get -y install libclang-${CLANG_VERSION}-dev

# pdraw dependencies
${SUDO} apt-get -y install build-essential yasm cmake libtool libc6 libc6-dev \
  unzip freeglut3-dev libglfw3 libglfw3-dev libsdl2-dev libjson-c-dev \
  libcurl4-gnutls-dev libavahi-client-dev libgles2-mesa-dev

# ffmpeg build dependencies
${SUDO} apt-get -y install rsync

# arsdk build dependencies
${SUDO} apt-get -y install cmake libbluetooth-dev libavahi-client-dev \
    libopencv-dev libswscale-dev libavformat-dev \
    libavcodec-dev libavutil-dev cython python-dev

# Bootstrap a python environment
# First, we need a temporary valid python environment for pip/virtualenv
PYTHON=/usr/bin/python3
BOOTSTRAP_DIR=/tmp/olympe/bootstrap
PYTHON_TMPENV_DIR="${BOOTSTRAP_DIR}/tmppython"
GET_PIP="${BOOTSTRAP_DIR}/get-pip.py"
rm -rf "${BOOTSTRAP_DIR}"
mkdir -p ${BOOTSTRAP_DIR}
wget https://bootstrap.pypa.io/get-pip.py -O "${GET_PIP}"

# Python 3 tmp env
mkdir -p "${PYTHON_TMPENV_DIR}/bin"
cp ${PYTHON} ${PYTHON_TMPENV_DIR}/bin
PYTHON=${PYTHON_TMPENV_DIR}/bin/python3
env -i PATH=/usr/bin:/bin ${PYTHON} -EsS "${GET_PIP}" --prefix "${PYTHON_TMPENV_DIR}" --no-warn-script-location virtualenv --ignore-installed

# Now that we have this new python env, create our definitive virtualenvs
PYTHONUSERBASE="${PYTHON_TMPENV_DIR}" ${PYTHON} -m virtualenv --copies -p ${PYTHON} ${PYTHON_ENV_DIR}/py3
PYTHON=/usr/bin/python3
rm -rf "${BOOTSTRAP_DIR}"

PY_REQS_TXT=$(find "${MODULES_DIR}/" -maxdepth 3 -mindepth 1 -name requirements.txt)

# Perform a clean pip installation of all dependencies:
#  - use ignore-installed to force the installation of a package even if it is
#    present outside the virtual env
#  - prior to this brutal installation, uninstall every dependencies so that
#    files that belong to a previous version of a dependency are removed
${ENV_DIR}/setenv pip uninstall --yes $(echo "$PY_REQS_TXT"|xargs -d '\n' -I{} echo -r {})
${ENV_DIR}/setenv pip install --ignore-installed $(echo "$PY_REQS_TXT"|xargs -d '\n' -I{} echo -r {})

# Add workspace builts python package directory to sys.path
PY_PRINT_VERSION=$(cat <<-END
from sys import version_info;
print('{}.{}'.format(version_info.major, version_info.minor))
END
)
PY_XY=$($PYTHON -c "$PY_PRINT_VERSION")
PY_PREFIX="$PYTHON_ENV_DIR/py3"
cp "${ENV_DIR}/python/sitecustomize.py" "$PY_PREFIX/lib/python$PY_XY"
3 Likes

Thank you so much. Should I just run this code in a terminal?

Hi,

You should apply the patch above (the first snippet) or completely replace the content of ./product/olympe/linux/env/postinst with the corrected version (the second code snippet above).
Then just execute this script again and follow the normal installation procedure from there.

Nicolas

Hi

I got the same problem and changed the postint file but I get a new error :

Traceback (most recent call last):
File “./takeoff.py”, line 3, in
import olympe
File “/home/linux/code/parrot-groundsdk/packages/olympe/src/olympe/init.py”, line 6, in
import olympe.arsdkng.module_loader
File “/home/linux/code/parrot-groundsdk/packages/olympe/src/olympe/arsdkng/module_loader.py”, line 60, in
from olympe.arsdkng.messages import ArsdkMessages, ArsdkMessage
File “/home/linux/code/parrot-groundsdk/packages/olympe/src/olympe/arsdkng/messages.py”, line 57, in
import olympe_deps as od
ModuleNotFoundError: No module named ‘olympe_deps’

Have you rebuild Olympe as explained in the installation procedure after running the modified postinst script ? ./build.sh -p olympe-linux -A all final -j4

thank you for your time and attention

yes I rebuild Olympe after modified postint script.

Hi
I tried on an other computer and I get the same error.
When I build and when I check the installation there is no error.
Thank.

Hi ! I tried to install Olympe with fixed postinst you linked here, but I’ve the same error than Sacha:
"ModuleNotFoundError: No module named ‘olympe_deps’ "

at " import Olympe "…

1 Like

Hi.
I used the patch you mentioned above, deleted all the file and redone all the procedure in the official wiki.
My error changes from “ImportError” to “ModuleNotFoundError: No module named ‘olympe_deps’”.
Interestingly, not like before, all the command didn’t report any errors, but “import olympe” did.
Looking forward to some workarounds for this issue.

3 Likes

Hello,
unfortunately i also have the same error. i tried it twice with a new ubuntu installation and the patch which was mentioned above.
could any of you come to a solution?
Thanks

1 Like

Alright, as you may know the postinst installation script has been hit by several dependency integration issue.

All this issues will (hopefuly) be fixed in the 1.2.0 up coming GSDK release that should be released in the few weeks from now.

In the meantime, It would be really helpful to post the postinst script execution logs here instead of the olympe_deps import exception error.

Otherwise, has anyone tried the manual installation procedure instead? It’s basically what the postinst script tries (and fails) to do.

Please report any issue about the installation procedures with a complete error log. Thanks

Nicolas

Hi.
I tried the manual installation in the wiki. Here are errors I encountered during the process.

ERROR: sphinxcontrib-seqdiag 2.0.0 has requirement Sphinx>=2.0, but you’ll have sphinx 1.8.5 which is incompatible.

I encountered this error when I am trying to install the dependencies in parrot-groundsdk/packages/olympe/requirements.txt. Perhaps the package sphinxcontrib-seqdiag also needs a specific version. I finally installed sphinxcontrib-seqdiag-0.8.5.

WARNING:clangparser:missing terminating ‘"’ character (/home/wangyz/code/parrot-groundsdk/packages/common/libvideo-buffers/implem/generic/include/video-buffers/vbuf_generic.h:355:38)
WARNING:clangparser:missing terminating ‘"’ character (/home/wangyz/code/parrot-groundsdk/packages/common/arsdk-ng/libarsdk/include/arsdk/arsdk.h:355:38)
WARNING:clangparser:missing terminating ‘"’ character (/home/wangyz/code/parrot-groundsdk/packages/common/arsdk-ng/libarsdkctrl/include/arsdkctrl/arsdkctrl.h:355:38)
WARNING:clangparser:missing terminating ‘"’ character (/home/wangyz/code/parrot-groundsdk/packages/common/arsdk-ng/libarsdkctrl/include/arsdkctrl/internal/arsdk_discovery_internal.h:355:38)

I found these warnings during the building. However, the script finally says Finished task 'alchemy'. I just ignored these warnings.
Here are the info by the script that might be useful.

  • ALCHEMY_WORKSPACE_DIR = /home/wangyz/code/parrot-groundsdk
  • TARGET_PRODUCT = olympe
  • TARGET_PRODUCT_VARIANT = linux
  • TARGET_OS = linux
  • TARGET_OS_FLAVOUR = native
  • TARGET_LIBC = native
  • TARGET_ARCH = x64
  • TARGET_CPU =
  • TARGET_OUT = /home/wangyz/code/parrot-groundsdk/out/olympe-linux
  • TARGET_CONFIG_DIR = /home/wangyz/code/parrot-groundsdk/products/olympe/linux/config
  • TARGET_CC_PATH = /usr/bin/cc
  • TARGET_CC_VERSION = 7

wangyz@Inspiron-7447:~/code/parrot-groundsdk$ source ./products/olympe/linux/env/shell
bash: /home/wangyz/code/parrot-groundsdk/.python//py3/bin/activate: No such file or directory.

(olympe-python3) wangyz@Inspiron-7447:~/code/parrot-groundsdk$ pip --version
Traceback (most recent call last):
File “/home/wangyz/.local/bin/pip”, line 7, in
from pip._internal.cli.main import main
ImportError: No module named _internal.cli.main

When I tried to get the version of pip in the virtual env, it reported error like this, and this is where i got stuck.

Hi !

You have a broken pip installation on your machine.

To repair your pip installation you should :

  1. try to :
    python3 -m pip uninstall pip
    (In your case this will uninstall ~/.local/bin/pip* after you’ve confirmed the uninstall)

  2. If 1. fails with a permission denied error, then you should just sudo the previous command:
    sudo python3 -m pip uninstall pip
    please note that you should AVOID AT ALL COST ANY sudo pip in the future if you don’t want to break your system package management tools (apt and python3-pip).

  3. If pip --version fails again then you have to (re-)install python3-pip :
    sudo apt install python3-pip --reinstall

Hi.
Thank you for your timely reply. But I still got errors like this in activating the virtual environment:

wangyz@Inspiron-7447:~/code/parrot-groundsdk$ source ./products/olympe/linux/env/shell
bash: /home/wangyz/code/parrot-groundsdk/.python//py3/bin/activate: No such file or directory.

However, I still got (olympe-python3) prompt after the error. And, I did get the response of pip --version, but the pip seems to be my system pip:

(olympe-python3) wangyz@Inspiron-7447:~/code/parrot-groundsdk$ pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)

Would you give me some workarounds in setting the right venv?
Thanks.

Hey! So i had the same issue with building Olympe on RP3b+ . If it helps this got the script up and running.
Please follow the following steps -

  1. From the folder parrot-groundsdk navigate to out/olympe-linux/final/usr/lib/python/site-packages/olympe_deps.py.
  2. Copy the file olympe_deps.py
  3. Paste the above file directly in the parrot-groundsdk folder

Please Note - I also faced the following issue after this, ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory · Issue #262 · Kitt-AI/snowboy · GitHub
To help solve the above mentioned issue, the following worked for me.

sudo apt-get install python3-pip python3-dev
wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v1.8.0/tensorflow-1.8.0-cp35-none-linux_armv7l.whl
sudo pip3 install /tensorflow-1.8.0-cp35-none-linux_armv7l.whl
sudo apt-get install libatlas-base-dev

Doing all the mentioned above, i could achieve Installation Ok for the following - python -c ‘import olympe; print(“Installation OK”)’ as mentioned in the olympe doc here - Installation - Olympe 1.8.0 documentation

2 Likes

Hi everyone,

The installation script has been fixed in the 1.2.0 GSDK release that has just gone live today.
Please let me know if that works for you, thanks.

Nicolas

Thank for the patch. I successfully installed the environment despite some warnings when I used the Manual dependency installation, maybe they are useful for you:

Ignoring faulthandler: markers 'python_version <= "2.7"' don't match your environment
Ignoring futures: markers 'python_version <= "2.7"' don't match your environment
Ignoring textwrap3: markers 'python_version <= "2.7"' don't match your environment

Everyting other than that seems to work fine.

By the way, since the olympe module runs in a virtual environment, how can I debug my script in IDEs like PyCharm?

Thanks.

Hi @wangyz ,

I am facing the same errors as yours. Please let me know if you have found a fix or what worked for you.

Thanks,
Gargi

Hey Gargi

I did never get it to work. I got help from a professor at my university, but even together, we could not fix it. I did however make a very nice project. I bought the Parrot AR 2 drone, and used a API called PS-drone. Amazing API, very user friendly.

Here is the API and a video from a guy using it :slight_smile:

1 Like