![]() ![]() As you can see, this function takes no arguments. This will execute the script just like if you’d execute it inside an IDE. Simply use python3 + the name of the file: python3 filename.py. Press F5 or Execute Icon as shown in Image. Run a Python script in the terminal of your Raspberry Pi All right, now that you have a Python script saved into a file, it’s time to run it directly from the terminal. ![]() ![]() First, your code should be saved to a file for Thonny to execute. You can find the documentation for the off() function here. There are 3 ways you can run the code you created. This would give me authoritative information about how many arguments the function requires (if at all it requires arguments), and of what kind. Instead, I would look at the documentation of the specific function in question. To fix it, I would start by not taking much note of the specific number of arguments that the error message indicates. From the interpreter dropdown list select MicroPython (Raspberry Pi Pico). But for now, it is worth taking into account the fact that this specific message can really throw you of and cause confusion, at least for a short time. Connect the Raspberry Pi Pico to your computer and in Thonny go to Tools > Options and click on the Interpreter tab. 02:15 As you can see here, Thonny is ready to run, and now we can start programming. pip will download all the relevant frameworks and Thonny itself and then install Thonny. You can play around with code snippets here, with the bonus that keywords and output will be nicely. 01:58 So here in the Terminal window, it’s possible to install Thonny using pip3 install thonny. The counting of positional arguments in MicroPython functions relate to the "self" keyword, and I address it in a dedicated lecture in the course. Starting IDLE will open a Python shell, just as you get when starting Python from the terminal. As you can clearly see, I have only given a single argument (not two, as the message claims), and I know that the correct number of arguments is zero (not one, as the message claims). The description suggests that the function "off" requires one positional argument, but that two arguments were given. This error message identifies the correct location of the bug, line 11. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |