AIP on Mac cannot import name reporting _download_http_url

NOTE - as this is my first post I have had to replace the slashes in links with ‘=’!

I was following the instructions to upgrade the WiFi software from the https:==wiki.seeedstudio.com=Wio-Terminal-Network-Overview= page and hit a few problems.

  • Intel Mac mini running OS Catalina 10.15.7
  • Python 3.8.2
  • Path = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Users/andrew/Library/Python/3.8/bin

First the commands reported an error unless I ran them using SUDO:

sudo python3 ambd_flash_tool.py erase
sudo python3 ambd_flash_tool.py flash -d =Users=andrew=Downloads=20201201-seeed-ambd-firmware-rpc-v2.0.3

On doing this, I finally managed to get the ambd_flash_tool.py installed and the firmware copied over to the device with a success message and closure of the tool being reported.

That left me with the Burn RLT8720 fw message on the screen but I cleared this by loading the ArduPy Firmware from https:==wiki.seeedstudio.com=ArduPy=

Trying to build the aip package using pip3 gives me a Successfully installed ardupy-aip-0.8.1 with the package installed in =Users=andrew=Library=Python=3.8=bin

I add this to the path by adding this line to .zshrc:
export PATH=$PATH:=Users=andrew=Library=Python=3.8=bin
and then restarted the terminal shell to bing this in to play.

Next running aip help reported the following error:

Traceback (most recent call last):
File “=Users=andrew=Library=Python=3.8=bin=aip”, line 5, in
from aip.main import main
File “=Users=andrew=Library=Python=3.8=lib=python=site-packages=aip=main.py”, line 39, in
from aip.parser import parser
File “=Users=andrew=Library=Python=3.8=lib=python=site-packages=aip=parser.py”, line 465, in
parser = Parser()
File “=Users=andrew=Library=Python=3.8=lib=python=site-packages=aip=parser.py”, line 73, in init
os.mkdir(self.user_config_dir)
FileNotFoundError: [Errno 2] No such file or directory: ‘=Users=andrew=.config=aip’

Creating the .config directory (mkdir =Users=andrew=.config) lets aip help get a bit further:

update local board json…
http:==files.seeedstudio.com=ardupy=package_new_seeeduino_ardupy_index.json
done!
Traceback (most recent call last):
File “=Users=andrew=Library=Python=3.8=bin=aip”, line 8, in
sys.exit(main())
File “=Users=andrew=Library=Python=3.8=lib=python=site-packages=aip=main.py”, line 52, in main
from aip.command import commands_dict, parse_command
File “=Users=andrew=Library=Python=3.8=lib=python=site-packages=aip=command.py”, line 46, in
from aip.build import buildCommand
File “=Users=andrew=Library=Python=3.8=lib=python=site-packages=aip=build.py”, line 34, in
from pip._internal.operations.prepare import (
ImportError: cannot import name ‘_download_http_url’ from ‘pip._internal.operations.prepare’ (=Library=Python=3.8=site-packages=pip=_internal=operations=prepare.py)

A check for http with grep http =Library=Python=3.8=site-packages=pip=_internal=operations=prepare.py only shows:

def get_http_url(
# See discussion at https:==github.com=pypa=pip=pull=6770
# http urls
file = get_http_url(

Any thoughts?

@Andyroo I see a screen full of “=”, what exactly is the problem?

Sorry about that - discord thinks Linux / Mac directory hierarchy are external links and blocks posts for new users.

Trying to run aip I get:

ImportError: cannot import name ‘_download_http_url’ from ‘pip._internal.operations.prepare’ (/Library/Python/3.8/site-packages/pip/_internal/operations/prepare.py)

Even building this in a virtual python environment reports the same issues. See here for another user with the same problem.

TBH - not very impressed so far. Python on this device is hit and miss (lots of misses no hit TBH). Project review is going to be interesting…

Trying a re-install of Python 3 from the official site gives the same error (different folder).
Trying a re-install of Python via brew gives the same error.

Looking at the source of prepare.py on GITHUB shows this function does not exist in the program…

I’m getting exactly the same message on all systems I’ve tried out yet (Windows, Ubuntu and even ARM64 Chromebook Linux VM)

(Need AIP SHELL because I’ve bricked my WioTerminal, have to delete the boot.py and can’t currently) :slightly_frowning_face:

I’ve got past that issue and put my workaround here - it’s due to Seeed not forking modules and calling functions deep in pip assuming they are still there in future versions.

Problem is that just leads to another error that I have no fix for.

I’ve opened a new question on how to actually use these things with Python and Macs but zero support so far. Purchasing looking into returning these as ‘not suitable for advertised use TBH’ so not sure if I’ll ever get and answer (or care) for the PM to document…

My workaround (did not fix all issues) here

PIP is already on version 20.3.3. here, so this should not be the problem
pip3 --version
pip 20.3.3 from c:\python38\lib\site-packages\pip (python 3.8)

Windows or Mac?

I see your output says C: as the start path inferring Windows. My issue is specifically on a Mac under Mac OS.

Main issue here is lack of support / comments from Seeed - my guess is the project will be killed over the holidays given current issues and kit returned for refund. I may be lucky and keep the kit I have at home but if this is the support then do I want it?

@Andyroo Could you try this again on a Python virtual environment?


Install Python 3 and latest version of pip3.

@uwe.fetzer
If you only need AIP SHELL because you have bricked your Wio Terminal and have to delete the boot.py, there is another workaround for this.
You could erase the flash by running the following in the Wio Terminal.

#include <sfud.h>

#define SFUD_DEMO_TEST_BUFFER_SIZE                     1024
static uint8_t sfud_demo_test_buf[SFUD_DEMO_TEST_BUFFER_SIZE];
static void sfud_demo(uint32_t addr, size_t size, uint8_t *data);

#define SERIAL Serial

void setup()
{
    SERIAL.begin(115200);
    while(!SERIAL) {};
    while(!(sfud_init() == SFUD_SUCCESS));
    /* erase test */
    const sfud_flash *flash = sfud_get_device_table() + 0;
    uint32_t addr = 0;
    size_t size = sizeof(sfud_demo_test_buf);
    uint8_t result = sfud_erase(flash, addr, size);
    if (result == SFUD_SUCCESS) {
        SERIAL.println("Erase the flash data finish");
    } else {
        SERIAL.println("Erase flash data failed");
    }
}

void loop()
{    
}

Open serial monitor inside Arduino IDE after the code is successfully uploaded.

Make sure to install the following libraries beforehand:
Seeed_Arduino_SFUD
Seeed_Arduino_FS

Best Regards,
Lakshantha

Hi Lakshantha,
perfect, this worked and the original empty main.py is there again (and no boot.py!).

Thank you very much!

Great!

Glad that it worked! Enjoy!

Had tried that previously (on other thread) to the same issue. Project now not going ahead with these boards due to lack of solid WiFi and Python support but boss says I can keep mine if I want - may stick it on eBay as I do not want to learn C but who knows.

Hi @Andyroo

I would suggest you take a look at this issue and follow the workarounds.

Mainly, try downgrading the pip version

Best Regards,
Lakshantha

Thank you but the older versions have security issues and as per my note the project will now be using different microcontrollers.

1 Like

Anyone else landing here via Google—I managed to work around this issue and more, which I documented in this report:

1 Like