Replies: 4 comments 2 replies
-
Is that a "desktop" Python module? Is it meant for a Raspberry Pi? Or how does it interface with the robot? |
Beta Was this translation helpful? Give feedback.
-
Perhaps off-topic, but I'll add it anyway: if the library is a single file, I would just ask my pupils/students to copy it to the directory of their project. I think that kids should also learn that there's nothing "magical" about creating libraries and showing them that it's just another Python file is a nice illustration of that. As this is not really an issue, I will convert this to a discussion in our discussion forum until we've figured out if there's something that needs to change in Mu. |
Beta Was this translation helpful? Give feedback.
-
I would have to check, but I believe the mu_code folder is added to the site-packages paths, so adding the package folder there should make it importable. Just need to make sure the folder structure is correct (it is not subnested in more directories than it needs). |
Beta Was this translation helpful? Give feedback.
-
The BirdBrain library is not meant for the raspberry pi. They have two "robot" kind of devices, one called a Hummingbird (which you attach sensors and output devices to) and the Finch 2, which is a self-contained robot. On your system is a "BlueBird Connector" which appears like a web server on a non-standard port to your app running on your system. The "BlueBird Connector" then takes those http requests and uses BLE to communicate to the device. Very nice for writing your own drivers. Young students also do very well with this. The BirdBrain Python library is just a single file with some class definitions, so there is no sort of packaging with the code. On my system (Mac with Big Sur), the sys.path contains: ['/Users/fmorton/tmp', '/Users/fmorton/.pyenv/versions/3.7.6/lib/python37.zip', '/Users/fmorton/.pyenv/versions/3.7.6/lib/python3.7', '/Users/fmorton/.pyenv/versions/3.7.6/lib/python3.7/lib-dynload', '/Users/fmorton/Library/Application Support/mu/mu_venv/lib/python3.7/site-packages'] I do not see mu_code in the path. For this case, it would be nice to have mu_code/site-packages, but this is probably an outlier. It is fine for me to put it in the mu_env site-packages. I just wanted to make sure there was not some well-known place to put files like this that I did not know about. I did try the third-party packages without success, but this library is not really a package. It is just a file with some class definitions. I will also consider the @dybber advise about just adding the library file with the project. One challenge with that is I plan to make changes to the library and I want to avoid old versions floating around. I don't actually copy it into the site-packages directory, but instead put a symbolic link pointing to the github repository on the systems that we put in a standardized place, so everyone is always using the latest library. BTW, the mu editor is absolutely fantastic with the birdbrain devices. You just use the Python 3 mode and everything works with almost no effort. Well done! |
Beta Was this translation helpful? Give feedback.
-
Birdbrain Technologies provides their library as a single file contain classes for their devices. The file is available at:
https://www.birdbraintechnologies.com/downloads/installers/BirdBrainPython.zip
To make this available in the Python 3 mode on a Mac, I copied the BirdBrain.py file into the site-packages directory buried under the Library/Application Support directory, specifically on my system:
~/Library/Application Support/mu/mu_venv/lib/python3.7/site-packages
Is this the best way to add a class library like this to sys.path?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions