7 years, 5 months ago.

mbed-cli - ImportError: No module named prettytable


I have tried to follow different links that are similar to this problem and as far as I have understood then mbed-cli should take care of the different missing python libraries.

The output of the import:

MacBook-Pro demo-72-import-cli $ mbed import http://mbed.org/teams/Semtech/code/LoRaWAN-demo-72/
[mbed] Importing program "LoRaWAN-demo-72" from "https://mbed.org/teams/Semtech/code/LoRaWAN-demo-72" at latest revision in the current branch
[mbed] Adding library "mbed" from "http://mbed.org/users/mbed_official/code/mbed/builds" at rev #6c34061e7c34
[mbed] Downloading library build "6c34061e7c34" (might take a minute)
[mbed] Unpacking library build "6c34061e7c34" in "/Users/svenkautlenbach/Documents/LoRaWAN-demo-72/mbed"
[mbed] Adding library "mac/LoRaWAN-lib" from "https://developer.mbed.org/teams/Semtech/code/LoRaWAN-lib" at rev #c16969e0f70f
[mbed] Adding library "radio/SX1272Lib" from "https://developer.mbed.org/teams/Semtech/code/SX1272Lib" at rev #e90cbf646eb1
[mbed] Couldn't find build tools in your program. Downloading the mbed 2.0 SDK tools...
[mbed] Auto-installing missing Python modules...

When compiling I get the error:

MacBook-Pro LoRaWAN-demo-72 (master) $ mbed compile -m TARGET_NRF51_DK -t TOOLCHAIN_GCC_ARM
[mbed] Auto-installing missing Python modules...
Traceback (most recent call last):
  File "/Users/svenkautlenbach/Documents/LoRaWAN-demo-72/.temp/tools/make.py", line 43, in <module>
    from tools.options import get_default_options_parser
  File "/Users/svenkautlenbach/Documents/LoRaWAN-demo-72/.temp/tools/options.py", line 18, in <module>
    from tools.toolchains import TOOLCHAINS
  File "/Users/svenkautlenbach/Documents/LoRaWAN-demo-72/.temp/tools/toolchains/__init__.py", line 35, in <module>
    from tools.memap import MemapParser
  File "/Users/svenkautlenbach/Documents/LoRaWAN-demo-72/.temp/tools/memap.py", line 11, in <module>
    from prettytable import PrettyTable
ImportError: No module named prettytable
[mbed] ERROR: "python" returned error code 1.
[mbed] ERROR: Command "python -u /Users/svenkautlenbach/Documents/LoRaWAN-demo-72/.temp/tools/make.py -t TOOLCHAIN_GCC_ARM -m TARGET_NRF51_DK --source . --build ./BUILD/TARGET_NRF51_DK/TOOLCHAIN_GCC_ARM" in "/Users/svenkautlenbach/Documents/LoRaWAN-demo-72"

I also checked the pip:

MacBook-Pro LoRaWAN-demo-72 (master) $ pip install prettytable
Requirement already satisfied: prettytable in /usr/local/lib/python2.7/site-packages

Python version is 2.7.10 installed with homebrew. mbed-cli installed by an install script from a official Github repo.

Thank you!

1 Answer

7 years, 5 months ago.

Hi Sven, I had similar issues when I started to use mbed-cli as well. If I remember correctly it was because OSX's python was still in the path.

Cheers, Jens

Accepted Answer

Thank you for your lead. As to this date, I do not know which mechanisms exactly the pip and python as they are installed on my machine do use. I did figure out that when entering python command line mode, the "import prettytable" indeed failed. I used sudo python -m pip install ... in order to install all the missing pieces.

posted by Sven Kautlenbach 19 Dec 2016