Install aioble with upip?

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
esp32bob
Posts: 7
Joined: Wed Oct 20, 2021 9:19 am

Re: Install aioble with upip?

Post by esp32bob » Thu Oct 21, 2021 8:12 am

If I copy

Code: Select all

__init__.py
to

Code: Select all

aioble.py
then I get this error:

Code: Select all

>>> import aioble.py
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "aioble.py", line 6, in <module>
ImportError: can't perform relative import

esp32bob
Posts: 7
Joined: Wed Oct 20, 2021 9:19 am

Re: Install aioble with upip?

Post by esp32bob » Thu Oct 21, 2021 8:28 am

davef wrote:
Thu Oct 21, 2021 7:04 am
When the files are copied to /pyboard/
then you should be able to do:

Code: Select all

cd /pyboard
repl
Ctrl-D
import aioble
Then we can deal with the errors that arise from that.
Finally got it all working. Thanks for your interest and help. I *was sure* I have tried this before, but here is what worked this time.
All in rshell.

Code: Select all

/pyboard> mkdir aioble
cp /opt/micropython-lib/micropython/bluetooth/aioble/aioble/* ./aioble
/pyboard> repl
Entering REPL. Use Control-X to exit.
>
MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32
Type "help()" for more information.
>>>
>>> import aioble
>>>
Can't explain why that didn't work before.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Install aioble with upip?

Post by davef » Thu Oct 21, 2021 8:34 am

Great. For my edification can you explain:

Code: Select all

cp /opt/micropython-lib/micropython/bluetooth/aioble/aioble/* ./aioble
/pyboard> repl
I would have expected the command to be:

Code: Select all

cp /opt/micropython-lib/micropython/bluetooth/aioble/aioble/* /pyboard/aioble/> repl
The specific part .... ./aioble/pyboard

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Install aioble with upip?

Post by dhylands » Thu Oct 21, 2021 6:03 pm

I think that the first command assumed that the current directory was /pyboard.

Using /pyboard/aioble eliminates the current directory from the equation (i.e. it will work regardless of the current directory is).

And to be clear, I'm saying that this:

Code: Select all

cd /pyboard
cp /opt/micropython-lib/micropython/bluetooth/aioble/aioble/* ./aioble
is equivalent to

Code: Select all

cp /opt/micropython-lib/micropython/bluetooth/aioble/aioble/* /pyboard/aioble
The first example that shows /pyboard> repl on the second line is showing the prompt (/pyboard>) followed by a command (repl).

The second example has an extraneous /> repl at the end of the line which shouldn't be there.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Install aioble with upip?

Post by davef » Thu Oct 21, 2021 6:35 pm

Dave,

Thank you for the clear explanation. When I saw ./aioble I thought it was running aioble like one does with a Bash or Python script from the command line.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Install aioble with upip?

Post by dhylands » Thu Oct 21, 2021 10:12 pm

./aioble is just a relative path. If it’s the first thing on the command line then you would be executing a program. If it’s not the first thing then is just an argument being passed to a program and could refer to a file or a directory.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Install aioble with upip?

Post by davef » Fri Oct 22, 2021 4:17 am

Thanks.

esp32bob
Posts: 7
Joined: Wed Oct 20, 2021 9:19 am

Re: Install aioble with upip?

Post by esp32bob » Sun Oct 24, 2021 5:58 am

dhylands wrote:
Thu Oct 21, 2021 6:03 pm
I think that the first command assumed that the current directory was /pyboard.

Using /pyboard/aioble eliminates the current directory from the equation (i.e. it will work regardless of the current directory is).

And to be clear, I'm saying that this:

Code: Select all

cd /pyboard
cp /opt/micropython-lib/micropython/bluetooth/aioble/aioble/* ./aioble
is equivalent to

Code: Select all

cp /opt/micropython-lib/micropython/bluetooth/aioble/aioble/* /pyboard/aioble
The first example that shows /pyboard> repl on the second line is showing the prompt (/pyboard>) followed by a command (repl).

The second example has an extraneous /> repl at the end of the line which shouldn't be there.
Sorry for the delay in replying. This is exactly what I was doing. I was already in

Code: Select all

/pyboard
and so used

Code: Select all

./aioble
rather than the more explict

Code: Select all

/pyboard/aioble
Thank you both for the help and information

PieyeGmbH
Posts: 3
Joined: Sun Aug 22, 2021 4:27 pm

Re: Install aioble with upip?

Post by PieyeGmbH » Tue Jun 27, 2023 10:34 pm

That might help:
https://github.com/micropython/micropyt ... ree/master

for me, the following did the trick:
import mip
mip.install("aioble")

import aioble

Post Reply