Python in EV3 - What modules are installed? - micropython

I have specific question. I have lego EV3 and i installed Micropython. But i want import turtle, tkinter and other modules and they aren't in micropython. But time module working.Do someone know what modules are in ev3 micropython? Thanks for answer.

welcome to Stackoverflow. MicroPython is very specific to the board it has been ported to run on. There are both standard libraries and hardware specific libraries in your MicroPython port and then open-source libraries you can install. I bet MOST of the Python and MicroPython specific libraries will be in your image. More on Libraries here: http://docs.micropython.org/en/latest/library/index.html
I did not see any online documentation for Lego's MicroPython version online. If you can find it, it may have this information. If so, please post back the link in the comments.
In the absence of good documentation you can discover what is available using help().
From the link above...
On some ports you are able to discover the available, built-in libraries that can be imported by entering the following at the REPL:
help('modules')
Your other question is will every Python library work on MicroPython? No. Most will not. You can search for libraries which will work on https://libraries.io. Just be sure to use the filters to narrow the results to MicroPython libraries.

If you are in fact running micropython, you're probably not going to find any of those modules. It has "micro" in the name of a reason; while it supports a great deal of Python 3 syntax, it is not fully compatible with C python and most modules not written explicitly for micropython won't work.
You can get a list of built-in modules by running help("modules"), and you can see any modules installed on the filesystem using os.listdir().

Related

How to use external modules in MicroPython on micro:bit from VSCode

I’m new to both micro:bit and MicroPython (or Python in general) - but I want to have it all running in VSCode. I grabbed this extension which was really smooth working with.
My problem now is that I want to leverage external modules, for things like the NeoPixels and also the bit:bot stuff, but I don’t know how to actually get that working. The NeoPixel tutorial is straight forward, but there is no mention on how to add the module.
I tried adding them with pip - but that won’t make them end up on the device. I’ve also tried this extension - hoping it would do some more magic in getting it onto the device.
Is this doable? Or would I have to revert do the online editors?
The micro:bit is a very constrained environment and will not run Python only MicroPYthon. MicroPython was designed to work under the constrained conditions of a microcontroller. As a result MicroPython does not come with the full Python standard library and only includes a small subset of the Python standard library.
For MicroPython to run on the micro:bit there needs to be the MicroPython hex file and any Python code that you have written, with main.py being the entry point.
The VS Code Extensions you linked to use uFlash to copy from your machine to the micro:bit the hex file and any Python files you have written.
To use the neopixel module it should be as straight forward as import neopixel as it is part of the standard BBC micro:bit MicroPython.
For BitBot, it only uses the standard micro:bit MicroPython library so I'm not sure what you are looking to import.
You can create a module by putting the code in .py file and referencing it in your main.py file. You do this by using an import statement that calls the file or specific parts of it.
MicroPython does have the concept of upip but I am not aware of that being available on micro:bit.

Alternative to GTK WIn7

I have begun to use GTK(2), and I find that the workings of the library to be very good, but the documentation sucks.
I want to upgrade to GTK3, but it seems I need to install something called packman. That is a difficult philosophical step for me. Why can't I simply download a zip file(s) somewhere?
The documentation uses a lot of words without saying much, and the downloads want you to download stuff OTHER then gtk in order to get gtk. Why don't they simply have a GTK package and let me decide if I need all the other stuff.
Also, I have been reading on forums, even if I do the packman stuff, it still isn't enough for C::B.
Anyway, that is mostly a rant, what I'd really like is a suggestion to an alternative to GTK+.
Here are some of my requirements...
#1, It must NOT be an interpreter. Using Code::Blocks and C, I get an exe file and I'd like to continue that way.
#2 It must be programmable using C. I'd really like to stick wiith C::B, but I guess in a pinch I can use Eclipse (although that is another nightmare I won't get into here.)
#3 GTK requires a bunch of DLL's to be shipped along with the exe file. It would be ideal if the entire target could be included in the single exe without having to rely on external dll's or .net framework or other external stuff.
Any suggestions woule be apreaciated.
Thanks, Mark.
You best bet is to give a look at https://en.wikipedia.org/wiki/List_of_widget_toolkits#High-level_widget_toolkits
If you wan to stick to C and not C++, then Qt is out.
The other that stands out is EFL. I've never used it myself, but it has good reputation and probably your best bet if you want to quit GTK+ and stick to C. However I don't know how easy it is to use it on Windows.
Now about GTK+:
Also, I have been reading on forums, even if I do the packman stuff, it still isn't enough for C::B.
There are people here that use GTK+ with Code::Blocks, so I don't get what kind of problem you're referring to.
Then your other problems:
The documentation uses a lot of words without saying much
Examples?
the downloads want you to download stuff OTHER then gtk in order to get gtk
What you don't get is that GTK+ is more that just the libgtk library. It has dependencies on a lot of other libraries, like glib, cairo, pango, etc. In the past there used to be a bundle or installer to have that installed on Windows, but people would mess up on setting the environment up based on their needs and give up. As the GTK+ manpower for the Windows platform is limited, the GTK+ team delegated the distribution of the GTK+ binaries to the MSYS2 project.
MSYS2 is a popular project that provides a lot of open source software already built for Windows, and solves the problem of building and installing dependencies by hand for the user. This step is made to make installation simpler, not harder. In a handful of commands you have GTK+ and all its dependencies installed for your platform, and can start coding your app. Another command and you have python and the python GTK+ bindings installed and can get started. Want to depend on another popular library? Chances are MSYS already provides it.
Windows has been known for decades to be bad on dependency management. If package management wasn't a a pain point on Windows, then stuff like chocolatey or conan wouldn't exist.
Your philosophical reluctance is merely that: philosophical. Sure GTK+ on Windows isn't perfect. With MSYS2 you will get packages built with gcc so the debug symbols are not compatible with the Visual Studio debugger and you will need to use gdb instead. But on your other question you say you use gcc and loathe Visual Studio, so this should not be a blocker to you.
GTK requires a bunch of DLL's to be shipped along with the exe file. It would be ideal if the entire target could be included in the single exe without having to rely on external dll's or .net framework or other external stuff.
This is not possible for the moment as static compilation of GTK+ isn't supported. The redistribution of an app, however, isn't as easy as I'd like it to be. The best way on Windows to redistribute your app while using MSYS2 is to create a pacman package for your app, listing its dependencies, then call pacman to install your app on an empty directory and tell it to install all your dependencies there too. The result will be a directory that you can redistribute, with a self-contained installation of your app and all its dependencies, GTK+ included.

How to build gnuradio without the documentation (from source)

I'm trying to build gnuradio 3.7.9 on raspberry pi as the version provided by apt-get has some problems.
However the classic cmake/make/mke install procedure tries to build the documentation which requires latex to be installed. As don't want to install latex, I'm looking for an option to build gnuradio without the documentation.
Any help appreciated
Cmake will just disable documentation of it doesn't find doxygen. And if doxygen doesn't find LaTeX, it should just skip the formulas.
Anyway, use cmake with the -DENABLE_DOXYGEN=OFF flag.
More importantly, don't build GNU Radio on the pi itself. The raspberry pi is an embedded device, not a compilation platform, to be honest. RAM will quickly become a bottleneck, and together with the limited storage bandwidth that means that even if successful, the build will take days.
Instead, spend that time on fixing whatever is wrong with the packet. I do happen to know the maintainer of the Debian gnuradio packages, and he's a really nice guy. If you can write a good bug report, I'm sure he, or the GNU Radio mailing list, will figure something out.

On using Lingua-TreeTagger-0.06

I am very, very new to NLP and the like. Therefore, I have a very basic question. I want to POS-tag an corpus of files with TreeTagger using a Mac OSX 10.6.8. I have installed TreeTagger by using the instructions provided at http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/
[I installed it in /Applications]
Then I have installed Lingua-TreeTagger-0.06 for 'for calling the TreeTagger and manipulating its output'. This took a lot of effort to do.
[I installed it in /Applications]
I think I have succeeded in the previous steps. Now what? I mean how do I call Tree-Tagger?
Thanks to anybody who could help me?
mc
Lingua::TreeTagger is a Perl module that is useful only if you want to use TreeTagger from within a Perl script. Examples of how to do so are given in the module's online documentation. Otherwise you should call the tree-tagger application from the terminal as commented by Patrick J.S. above (unless you are on Windows, where a user-friendly graphical interface is available).

easy_install, pip, py3, and official IPython documentation

Today I noticed this fairly old (and highly voted) question and it made me wonder, if pip is generally preferred over easy_install in the Python community, why is the official ipython.org documentation instructing newcomers like me to use easy_install as shown here?
Perhaps there is an implicit assumption that readers are using Python 2? Although the highly voted question and several answers all seem to indicate that pip is widely preferred over easy_install for both py2 and py3, so that seems like it's not the answer...
The command:
easy_install ipython[zmq,qtconsole,notebook,test]
will install IPython and some dependencies, including pyzmq, which has compiled parts.
easy_install handles binary packages, so it can install precompiled versions of things like pyzmq. pip, by contrast, only works with source packages. So for a package with compiled parts, it downloads the source code and tries to compile it. There are two problems with that:
The user needs to have a C compiler installed, plus whatever development headers the code being compiled relies on. The user often doesn't.
It's slow, especially for larger packages.
So the scientific Python world, which uses a lot of compiled packages, doesn't use pip as much as web developers. Actually, we don't much like easy_install either - we have a variety of more powerful installation methods.