Install aip on Mac High Sierra

Hello, i tried to install aip on Mac following https://wiki.seeedstudio.com/ArduPy/#install-aip-with-macos 1) homebrew 2) python3 3) pip3 install ardupy-aip
I had to manually create dir .config, then install went smooth, but if i tried to run aip i got this error :

File “/usr/local/bin/aip”, line 8, in
sys.exit(main())
File “/usr/local/lib/python3.9/site-packages/aip/main.py”, line 52, in main
from aip.command import commands_dict, parse_command
File “/usr/local/lib/python3.9/site-packages/aip/command.py”, line 46, in
from aip.build import buildCommand
File “/usr/local/lib/python3.9/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’ (/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py)

Many thanks for any help.

seems like your pip3 path is not in your $PATH? you may try echo $PATH and see

Hi, many thanks, looks like, it really isnt there. But it didnt help,
my echo $PATH looks like:
/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin/python3:/Applications/VMware Fusion.app/Contents/Public

Error message :
Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.9/bin/aip”, line 8, in
sys.exit(main())
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aip/main.py”, line 52, in main
from aip.command import commands_dict, parse_command
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aip/command.py”, line 47, in
from aip.install import installCommand
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aip/install.py”, line 34, in
import requests
ModuleNotFoundError: No module named ‘requests’

Do you have a complicated python env? Seems like the script not wokring properly. Can you run pip3 install request request

Output :
ERROR: Could not find a version that satisfies the requirement request (from versions: none)

ERROR: No matching distribution found for request

WARNING: You are using pip version 20.2.3; however, version 20.3 is available.

You should consider upgrading via the ‘/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -m pip install --upgrade pip’ command.

Please could you try the installtion in a python virtual env such as this: https://docs.python.org/3/tutorial/venv.html

Hi, many thanks, now it works. But after all this effort i found that Python libraries exist only for few components, but not for EC sensor which i need.

1 Like

Anyone with a fix for the original error ( ‘_download_http_url’ from ‘pip._internal.operations.prepare’ ) under Catalina? Looking at the source code on GITHUB for ‘prepare’ the function is not present…

Tried both python.org and brew versions of Python and virtual environment.

I’m also under macOS Catalina and works fine, can you show us the full error msg?

The command I am issuing is the aip help from terminal as a normal user and I get back:

update local board json...
http://files.seeedstudio.com/ardupy/package_new_seeeduino_ardupy_index.json
done!
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/bin/aip", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aip/main.py", line 52, in main
    from aip.command import commands_dict, parse_command
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aip/command.py", line 46, in <module>
    from aip.build import buildCommand
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aip/build.py", line 34, in <module>
    from pip._internal.operations.prepare import (
ImportError: cannot import name '_download_http_url' from 'pip._internal.operations.prepare' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/operations/prepare.py)

This is with Python 3.8.6 installed from python.org and the local version installed with brew removed.
Pip3 reports version 20.3.3 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)

seems like an error from pip version 20:

Can you check the solution here for virtual env:

Tried a couple of things based on that link but aip still references the base pip in the /Library/Frameworks rather than the virtual env.

Next is to try zapping Python and pip off the machine but get the feeling that a supplier of dev tools that is relying on old versions of packages (without forking the code) will be frowned on and that’s before we start development :frowning: :roll_eyes:

Well that did not work. Mac has:

  • Python 2.7.16
  • Python 3.8.6
  • Pip 18.1 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)

BUT as part of the install I get:

ardupy-aip 0.8.1 requires pip>=20.1, but you’ll have pip 18.1 which is incompatible.

So upgrading pip to 20.1 with sudo -H python3 get-pip.py pip==20.1 gives a different error:

ModuleNotFoundError: No module named ‘requests’

but a quick sudo -H pip install requests gives me an aip command that does not error on the help!

So it looks like the process is:

  1. Install Python 3 on the Mac from python.org
  2. Download get-pip.py
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  3. Run that to install version 20.1
    sudo -H python3 get-pip.py pip==20.1
  4. Add the ‘requests’ module using pip sudo -H pip install requests

This MAY work in a virtual env but I’m not testing that til 2021.

FORGET IT - the next thing I try dies with

FileNotFoundError: [Errno 2] No such file or directory: '/Users/andrew/.config/aip/modules’

Going to ask for working instructions from the devs.

I have the same issue attempting to run aip on a fresh Raspberry Pi 400 install, only with Python 3.7:

$ aip help
Traceback (most recent call last):
  File "/home/pi/.local/bin/aip", line 10, in <module>
    sys.exit(main())
  File "/home/pi/.local/lib/python3.7/site-packages/aip/main.py", line 52, in main
    from aip.command import commands_dict, parse_command
  File "/home/pi/.local/lib/python3.7/site-packages/aip/command.py", line 46, in <module>
    from aip.build import buildCommand
  File "/home/pi/.local/lib/python3.7/site-packages/aip/build.py", line 34, in <module>
    from pip._internal.operations.prepare import (
ImportError: cannot import name '_download_http_url' from 'pip._internal.operations.prepare' (/home/pi/.local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py)

OK, my workarounds (multiple problems):

I checked the code, and found it did not actually use _download_http_url. Or, at least not in any of the files I checked!

So I removed _download_http_url from the imports from the following files:

  • build.py
  • install.py
  • uninstall.py
  • shell.py
  • flash.py

and now ‘aip help’ works for me. That’s probably the right fix, as far as it goes, but it’s not enough.

  • I had to manually create the directory ~/.config/api/modules

Then:

ERROR: unpack_url() got an unexpected keyword argument 'downloader'
ERROR: Exception:
Traceback (most recent call last):
  File "/Users/rwk/opt/anaconda3/envs/arduino/lib/python3.7/site-packages/aip/build.py", line 325, in downloadAll
    download_dir=None,
TypeError: unpack_url() got an unexpected keyword argument 'downloader'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rwk/opt/anaconda3/envs/arduino/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 189, in _main
    status = self.run(options, args)
  File "/Users/rwk/opt/anaconda3/envs/arduino/lib/python3.7/site-packages/aip/build.py", line 382, in run
    self.downloadAll(seesion)
  File "/Users/rwk/opt/anaconda3/envs/arduino/lib/python3.7/site-packages/aip/build.py", line 329, in downloadAll
    os.remove(ardupycoredir)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/rwk/.config/aip/ardupycore/Seeeduino/hardware/samd/1.3.0/core'

For this, I compared the build.py code with the prepare.py code, and found they disagree about the ‘downloader’ argument.

build.py calls it as a keyword argument, e.g. ‘downloader=downloader’.
prepare.py expects it as a positional argument.
Replacing ‘downloader=downloader’ in two places in build.py seems to resolve that.

The next problem I had is that ‘aip board’ failed. It really does not like my XIAO-based Altoid MIDI Box, which indeed is not an Ardupy device—but it should not refuse to list my WIO. My workaround here (for now) is to unplug my Altoid MIDI Box, but WTF? I am going to have to come up with a fix for that, too. MIDI devices disappearing confuse Logic Pro X.

Finally, ‘aip install’ failed, also due to the mismatch of arguments to unpack_url. The fix was again, in two places, to replace ‘downloader=downloader’ with just ‘downloader’.

This finally got me to where I seem to have a working install. All the commands appear to work.

This is all the sort of stuff that shouldn’t make it into the wild—but I’m not sure what to suggest! Perhaps the hardware access could be mocked, and CI tests run against that? You really don’t want to rely on humans testing this stuff. I’d be happy to work with y’all to improve the build/release process, but of course, I don’t know your starting point or what issues you face.

1 Like

Hi @BobKerns,

Thank you very much for your workarounds! Great to see valuable help from the community! Really appreciate your efforts!

As a result, we have updated the latest version to PyPI already.

Best Regards,
Lakshantha