[Microbit-Python] Can't get MU to run on MACbookAir

David Whale david at thinkingbinaries.com
Wed Aug 3 13:17:00 EDT 2016


Regarding...

*>>What is syntactically incorrect with the statement:-*
*>>from microbit import *  *

*>>When I click the CHECK button, I get*
*>> ‘ from microbit import * ‘  used; unable to detect undefined names  [In
English we would understand that ‘If you say words I don’t understand, I
can’t help you’]*

and..

*>>OK... I've just read Radomir's reply. He's nailed it. I can't improve on*
*>>his explanation of this message.*

Nicholas, this is a very confusing message indeed! - why does Mu not know
what is in the microbit package, as Mu is written to develop code for the
micro:bit and surely if it is doing code completion, it must have access to
the 'known' directory of methods that the microbit libraries use?

For a newbie, such a message is confusing - can it be suppressed, or the
underlying visibility issue with the microbit module within Mu be fixed?
The first experience is when you first do that import, and it should be a
good experience, not one that bombards you with warnings that look like
errors!

Many thanks!

David


___________________________________________________________
David Whale, B.Sc (Hons), MIET
*Software Engineer and IET Schools Liaison Officer, Essex*


On 3 August 2016 at 17:25, Robert Humphrey <humphrey.robert at orange.fr>
wrote:

> Great - thanks for the reply.  I am hoping that my daughter brings me over
> my Microbit in a week or twos time.
> Bob
>
> On 03 Aug 2016, at 16:46, Nicholas H.Tollervey <ntoll at ntoll.org> wrote:
>
> Hi Bob,
>
> Comments in-line below. :-)
>
> N.
>
> On 03/08/16 14:55, Robert Humphrey wrote:
>
> Yes,  sort of.   The Microbit has 32K memory.  Are you saying that a
> Python 3.6  19Mb zip file expands into 32K on the Microbit ??  That
> can’t be right - can it?
>
>
> The 19mb 3.6 version of Python you downloaded from python.org is not the
> same as the version of Python on the micro:bit. Python 3.6 for your
> computer comes with a bunch of libraries and tools. Python on the
> micro:bit is, in fact, MicroPython - an amazing project since it
> reimplements Python 3 but for constrained computing environments like
> the micro:bit. However, MicroPython doesn't come with all the libraries
> and tools, it's only just large enough to fit on the micro:bit..!
>
> Having said that, MicroPython is still Python and remarkably powerful.
> I'm sure you'll have fun working through the tutorials!
>
>
> Regarding Python 3.6 on a MAC.  I think you are saying that I should not
> have Python 3.6 on the MAC at all,  but MU on the MAC
>
>
> Having Python on your Mac is a good idea since you'll be able to play
> with Python. However, a Mac is not a micro:bit and, as a result, the
> version of Python on the Mac won't include the micro:bit libraries we
> use in our documentation.
>
> My Microbit has not arrived yet - I am just trying to understand Python
> (or something) pre arrival.  MUST I always have the microbit attached to
> the MAC to write code?
>
>
> You can write code without the device being plugged in. However, you
> still need a device upon which to run the code. Hence, once you plug it
> in, you simply click "flash" to put your code on the device.
>
> If not then why when I write a line of code
>
> from microbit import *  do I get the message IMPORT error  ‘No module
> named microbit’  Please see the attached screen shot on last E-mail.  If
>
>
> As I think I may have mentioned - these are not errors. These are style
> guides. I think, in future, I'll follow some advice that Radomir
> suggested: colour error messages in red and stylistic messages in blue
> so they don't look so problematic.
>
> I use the web based interactive version, my Python code doesn’t seem to
> have errors
>
>
> Writing code in an editor is not the same as running it. Mu is simply
> trying to help you write stylistic Python so that it's easy for others
> to understand. The web based editor (which I also wrote) is rather
> limited so doesn't check your code for style.
>
> To be clear, what you're seeing are not errors - just style guidance.
>
> As regards MU,  the screen shot shows “errors" on every line or are
>
>
> Nope... they're not errors! :-)
>
> these some form of helpful comments?  Yes,  it does produce a .hex file
> (which has data in it).
>
>
> Great, these are helpful comments.
>
> If you get a .hex file then everything is ready for when you plug in
> your micro:bit. At that point, when you click "flash" Mu will detect
> where your device is and copy over your code for you. If it can't find
> it, it'll simply ask you where it is (you choose from a file system
> dialogue).
>
>
> What is syntactically incorrect with the statement:-
> from microbit import *
>
> When I click the CHECK button, I get
> ‘ from microbit import * ‘  used; unable to detect undefined names  [In
> English we would understand that ‘If you say words I don’t understand, I
> can’t help you’]
>
>
> OK... I've just read Radomir's reply. He's nailed it. I can't improve on
> his explanation of this message.
>
> Please
> Bear with this old duffer - remember that in my day,  hard drives were
> only 25Mb, dates were held as compressed ASCII 5 byte strings (years ran
> from 0-9 and A-Z), Lowercase and fonts had not arrived and TELEX was new
> and FAX hadn’t arrived.  Input was by paper tape or punched card and
> VDUs - (Screens to you) were for the computer operator. ROM was made
> from diode arrays and memory was magnetic core.  My first home computer
> has 256 bytes of data and Binary had 3 states - Off, On  and don’t know
> (Voltage region between -0.3 to +0.3 volts) and programmed in Hex
> machine code.
>
>
> Oh boy! That sounds amazing. You should write up your experiences from
> "back in the day" (as it were) and compare / contrast them to your
> experience with MicroPython on the micro:bit. I'd love to read something
> like that!
>
> Here I was thinking I was old because I remember the old 8-bit machines
> I used as a kid in the 1980s (such as the original BBC micro).
>
> So, please don't worry about old-duffer-hood. :-)
>
> Happy to help in any way that I can, and, as I think you're finding out,
> the Python community is friendly, helpful, well organised and full of
> opportunity to learn. Just dive in and ask!
>
> Best wishes,
>
> N.
>
>
> Thanks    Bob
>
>
>
>
>
> On 03 Aug 2016, at 13:12, Nicholas H.Tollervey <ntoll at ntoll.org
> <mailto:ntoll at ntoll.org <ntoll at ntoll.org>>> wrote:
>
> Hi Bob,
>
> From the screenshots, it appears that Mu is working fine on your
> Macbook. I'm trying to work out what it is that *isn't* working for you.
>
> Please bear with me if any of the following is obvious ~ I just want to
> make sure you've set yourself up properly.
>
> 1) Mu is working.
> 2) Plug in a micro:bit device to your Macbook via USB.
> 3) Click on the flash button and your script (in the Mu editor) will be
> transferred (flashed) onto the micro:bit (should take around 6 seconds).
> If there are any errors they'll scroll across the micro:bit's display.
> 4) Click on the REPL button to get access to the interactive prompt for
> the version of Python running on the micro:bit.
>
> You don't need to install Python 3.6 onto your Macbook - you should be
> using the version of Python *on* the actual device itself. For this to
> work you flash the device with the MicroPython runtime as I described in
> step 3 above. Following that, you get access to the Python prompt by
> clicking the REPL button.
>
> Does this make sense?
>
> Best of luck,
>
> N.
>
> On 02/08/16 16:35, Robert Humphrey wrote:
>
> Thanks for the response.  I find it hard work trying to install Micro
> Python, and thanks for bearing with me.  The attached screen shot is
> typical. It appears that there in’t a library to import.
>
> I followed your link via Pep-8, installed Python 3.6,  installed Active
> tcl 8.6. Ran Python 3.6 and get errors.   I re-tried MU and again it
> appears that there are no libraries to import. Is there a simple way to
> get all this working as I can get Python to work interactively from the
> net at W3. microbit.Pythonanywhere.com
> <http://microbit.pythonanywhere.com/>
> <http://microbit.pythonanywhere.com/>
> <http://microbit.pythonanywhere.com
> <http://microbit.pythonanywhere.com/>>,  but no luck locally.
> Bob
>
>
>
> ote:
>
> On 02/08/16 13:37, Robert Humphrey wrote:
>
> I have installed MU from GitHub latest  MU-3  30/07/2016  but it
> errors out on every statement.  What haven’t I loaded?
>
> Op Sys  OSX  El Capitaine
>
> Example code:-
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> <mailto:Microbit at python.org <Microbit at python.org>> <
> mailto:Microbit at python.org <Microbit at python.org>>
> https://mail.python.org/mailman/listinfo/microbit
>
>
> Hi Robert,
>
> Thanks for the feedback.
>
> In future, please just attach the PNG image file rather than sticking
> the screen shot in a PDF - it's just simpler and I don't have to twist
> my neck to see what you're up to (I sprained it trampolining over the
> weekend). :-)
>
> So, I'm trying to work out what exactly you mean. Do you mean that Mu
> has an error in it and crashes OR that Mu is reporting errors for every
> line in your code? Looking at your screenshot, I believe you're
> reporting the latter.
>
> If so, these are not errors!
>
> Rather, they are code quality feedback annotations. Your code probably
> will still work, but it has stylistic problems. For example, I can see
> from lines 5-8 you use a comment "#" without following it with a space
> (to aid readability). If you click on the red arrow next to each line a
> little post-it note will appear to explain why the line has been
> flagged.
>
> Such code quality checking is advisory! Unless you get syntax errors
> your code will run (although it may still contain bugs because it
> doesn't work as you expect).
>
> If you're interested in the conventions Mu uses for checking the quality
> of your code you should read up on PEP-8 - the style guide for Python
> programming (it's like the style guide newspapers use to guide their
> journalists in writing in an idiomatic and "house" style).
>
> https://www.python.org/dev/peps/pep-0008/
>
> PEP-8 was written by Python's creator Guido van Rossum and a couple of
> other collaborators (including Nick Coghlan, who may be subscribed to
> this list). It's their vision of well written, idiomatic Python. Many
> Python programmers, myself included, use it for guidance when writing
> code.
>
> You are free to ignore it though. As PEP-8 itself says, "a foolish
> consistency is the hobgoblin of little minds".
>
> :-)
>
> Hope this helps, and more than happy to answer any questions you may
> have.
>
> N.
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org <mailto:Microbit at python.org <Microbit at python.org>>
> https://mail.python.org/mailman/listinfo/microbit
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org <mailto:Microbit at python.org <Microbit at python.org>>
> https://mail.python.org/mailman/listinfo/microbit
>
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20160803/c3f3d320/attachment-0001.html>


More information about the Microbit mailing list