Why can't I import and use machine.SoftI2C in Micropython v.1.13 on ESP32? - i2c

This relates to an ESP32 development module (from Amazon, similar to the DoIt module). I have Micropython v1.13 (Sep 2020) installed. According to the Micropython documentation
http://docs.micropython.org/en/latest/library/machine.I2C.html?highlight=i2c#machine.I2C
there is a class 'machine.SoftI2C(scl, sda, *, freq=400000, timeout=255)'. By my reckoning, I should be able to do:
'from machine import SoftI2C'
But it gives the error:
ImportError: 'can't import name SoftI2C'
SoftI2C is not listed when using 'help(machine)' (after 'import machine'), whereas I2C is. SoftI2C does not seem to exist.
This also applied to MicroPython v1.12
Any thoughts, anyone??

You're running version 1.13, but it looks like the SoftI2C name was introduced in commit c35deb2, which post-dates the 1.13 release.
It may be that the "latest" documentation tracks the head of the repository rather than the most current stable release. You can find the 1.13 docs here, and you'll note there is no notice of SoftI2C.
Try running a more recent build (I'm running one I downloaded today), which seems to be working fine).

Related

How can I fix the attribute error in VS code when the same code runs perfectly on colab?

I was running the PySINDy package and I kept on getting the module not found-error when I ran this:
pip install pysindy
import pysindy as ps
I fixed this by downgrading the Python in my VS code to 3.8.9. But I do get the following note:
note: This error originates from a subprocess, and is likely not a problem with pip.Note: you may need to restart the kernel to use updated packages.
I am now getting the attribute error when I run the following:
differentiation_method = ps.FiniteDifference(order=2)
Here's the error:
AttributeError: module 'pysindy' has no attribute 'differentiation'
Can someone please help me with this? (I successfully ran the entire code earlier on google colab and the online Jupyter, but I am unable to do it locally. I use MAC os and Jupyter via VS Code.)

emacs: package-name is an available obsolete package

Whenever I install a MELPA package, I get this message:
package-name is an available obsolete package
Here is a screenshot of what I mean (first line):
I tried this solution but it did not help.
How to fix it?
That message confused me too. It turns out it's just a poor choice of words for saying that there's a new version available.
https://lists.gnu.org/archive/html/help-gnu-emacs/2019-02/msg00082.html
Once you update the list of packages with M-x package-refresh-contents, then you can type U x and it will upgrade all installed packages that have a more recent version available.
Once that is done, the message you see when you open the description of an updated package will be:
Package x is installed.

Google Cloud ML scipy.misc.imread returning <PIL.JpegImagePlugin.JpegImageFile>

I am running the following snippet:
import tensorflow as tf
import scipy.misc
from tensorflow.python.lib.io import file_io
file = file_io.FileIO('gs://BUCKET/data/celebA/000007.jpg', mode='r')
img = scipy.misc.imread(file)
If I run that snippet in Cloud Console, I get back a proper array. But when that same snippet runs in Cloud ML, the img object is
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=178x218 at 0x7F1F8F26DA10>
This stackoverflow answer suggests that libjpeg was not installed when PIL was installed. The Cloud ML Runtime Version list shows that for Tensorflow 0.12, libjpeg-dev is an installed debian package.
I was able to reproduce this issue on Cloud ML, and it seems to be an issue with the version of file_io in Tensorflow 0.12.1, and goes away if Tensorflow 1.0 is installed.
If you can, upgrade to the 1.0 build of TF.
If you need a 0.12 version, the Cloud ML "0.12" runtime uses the official 0.12.1 build of TF, but you can upload your own version to install if you like. I did not track down exactly when the issue was fixed but a Nightly Tensorflow build from Feb 2nd seemed to work.

Installing Tensorflow from source

I've been trying to install Tensorflow and get it working over the past few days. Whilst I have managed to install TF and get it working as tested by opening Python in the terminal and typing,
import tensorflow as tf
I have not been successful attempting to retrain Inception v3. I managed to install it from source once by following the instructions laid out here however I am no longer able to do so. When I get to the section 'Create the pip package and install' and go to run bazel build -c opt //tensorflow/tools/pip_package:build_pip_package in the root of my Tensorflow directiory I get the following error.
kieran#kieranUbuntu:~/tensorflow$ bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
ERROR: /home/kieran/tensorflow/tensorflow/core/BUILD:1068:1: no such target '//tensorflow/tools/git:gen/spec.json': target 'gen/spec.json' not declared in package 'tensorflow/tools/git' defined by /home/kieran/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'.
ERROR: /home/kieran/tensorflow/tensorflow/core/BUILD:1068:1: no such target '//tensorflow/tools/git:gen/head': target 'gen/head' not declared in package 'tensorflow/tools/git' defined by /home/kieran/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'.
ERROR: /home/kieran/tensorflow/tensorflow/core/BUILD:1068:1: no such target '//tensorflow/tools/git:gen/branch_ref': target 'gen/branch_ref' not declared in package 'tensorflow/tools/git' defined by /home/kieran/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'.
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted.
INFO: Elapsed time: 3.063s
This is the same error I ran into when I managed to install it and then attempted retaining the classifier following this tutorial. At the section, bazel build tensorflow/examples/image_retraining:retrain.
I just can't figure out what is going wrong and I have been trying for so long.
I'm using this pip version, # Ubuntu/Linux 64-bit, CPU only, Python 2.7
I think you should search before ask, This link can probably solve your issue.
The issue lied in the incorrect use of ./configure. Whilst it was ran I currently have two versions of python on my computer, both of which are stored in different locations, when running ./configure I pointed it to the wrong python version. After rectifying the issue everything worked correctly.

CPAN - Specio::Constraint::Simple install error

Attempting to install Specio::Constraint::Simple, running into the following error:
Can't resolve method "???" overloading "&{}" in package
"Specio::Constraint::Simple" at Specio::Constraint::Simple->new line
35.
Only related article I have found has been: https://rt.cpan.org/Public/Bug/Display.html?id=117975
Any suggestions would be appreciated.
Thank you
This is caused by a bug in older versions of Role::Tiny that was fixed in version 1.003003:
overloads specified as method names rather than subrefs are now applied
properly
Upgrading Role::Tiny should fix it and allow Specio::Constraint::Simple to be installed normally.
Actually, you don't even need to do that manually: Version 0.26 of Specio now requires at least version 1.003003 of Role::Tiny. Any future attempt to install Specio will upgrade Role::Tiny automatically (if required).