2 years, 4 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
[mbed] Importing program "LoRaWAN-demo-72" from "" at latest revision in the current branch
[mbed] Adding library "mbed" from "" 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 "" at rev #c16969e0f70f
[mbed] Adding library "radio/SX1272Lib" from "" 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/", line 43, in <module>
    from tools.options import get_default_options_parser
  File "/Users/svenkautlenbach/Documents/LoRaWAN-demo-72/.temp/tools/", line 18, in <module>
    from tools.toolchains import TOOLCHAINS
  File "/Users/svenkautlenbach/Documents/LoRaWAN-demo-72/.temp/tools/toolchains/", line 35, in <module>
    from tools.memap import MemapParser
  File "/Users/svenkautlenbach/Documents/LoRaWAN-demo-72/.temp/tools/", 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/ -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!

Comment on this question

1 Answer

2 years, 4 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

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

To post an answer, please log in.