Adafriut LED backpack - led

Adafruit LED backpack
Am I being stupid (probably yes)
I'm after python 3 versions of this module, every time I download it I get the python 2.7 versions
getting my module from
git clone https://github.com/adafruit/Adafruit_Python_LED_Backpack.git
I'm doing this on a raspberry pi
the python 2 version works fine but my program is written in python 3
new error I'm getting is:
Traceback (most recent call last): File
"/home/pi/Adafruit_Python_LED_Backpack/matrix8x16_test.py", line 37,
in
display.begin() File "/home/pi/Adafruit_Python_LED_Backpack/Adafruit_LED_Backpack/HT16K33.py",
line 53, in begin
self._device.writeList(HT16K33_SYSTEM_SETUP | HT16K33_OSCILLATOR, []) File
"/usr/local/lib/python3.4/dist-packages/Adafruit_GPIO/I2C.py", line
127, in writeList
self._bus.write_i2c_block_data(self._address, register, data) File
"/usr/local/lib/python3.4/dist-packages/Adafruit_PureIO/smbus.py",
line 274, in write_i2c_block_data
self._device.write(data) OSError: [Errno 5] Input/output error

this package seems to be compatible between both python 2 & 3.
after cloning the package, when you want to install it in python interpreter, execute this command:
sudo python -3 setup.py install
'-3' means running on python 3.

Related

Can't run Apache Beam on separate Flink cluster. Official instructions don't work

LE: I want to do this on macOS.
I am trying to run Apache Beam on a separate Flink cluster, as described here: https://beam.apache.org/documentation/runners/flink/#executing-a-beam-pipeline-on-a-flink-cluster
(1) Start a Flink cluster which exposes the Rest interface
(e.g. localhost:8081 by default).
Flink 1.13.1 starts successfully on localhost:8081.
(2) Start JobService with Flink Rest endpoint: docker run --net=host apache/beam_flink1.10_job_server:latest --flink-master=localhost:8081.
I am running this instead, which again starts successfully:
docker run --net=host apache/beam_flink1.13_job_server:latest --flink-master=localhost:8081
(3) Submit the pipeline as above.
I'm running the WordCount pipeline as:
python -m apache_beam.examples.wordcount --input /Users/stefan/datastore/input.txt
 --output /Users/stefan/datastore/output.txt
 --runner=PortableRunner --job_endpoint=localhost:8099
After 1 minute the pipeline crashes with a grpc.FutureTimeoutError. This is the full output:
WARNING:root:Make sure that locally built Python SDK docker image has Python 3.8 interpreter.
INFO:root:Default Python SDK image for environment is apache/beam_python3.8_sdk:2.31.0
INFO:root:No image given, using default Python SDK image
WARNING:root:Make sure that locally built Python SDK docker image has Python 3.8 interpreter.
INFO:root:Default Python SDK image for environment is apache/beam_python3.8_sdk:2.31.0
INFO:root:Python SDK container image set to "apache/beam_python3.8_sdk:2.31.0" for Docker environment
INFO:apache_beam.runners.portability.fn_api_runner.translations:==================== <function pack_combiners at 0x137d441f0> ====================
INFO:apache_beam.runners.portability.fn_api_runner.translations:==================== <function lift_combiners at 0x137d44280> ====================
INFO:apache_beam.runners.portability.fn_api_runner.translations:==================== <function sort_stages at 0x137d449d0> ====================
Traceback (most recent call last):
File "/usr/local/Cellar/python#3.8/3.8.11/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/Cellar/python#3.8/3.8.11/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/stefan/workspace/biodiversity/.env/lib/python3.8/site-packages/apache_beam/examples/wordcount.py", line 94, in <module>
run()
File "/Users/stefan/workspace/biodiversity/.env/lib/python3.8/site-packages/apache_beam/examples/wordcount.py", line 89, in run
output | 'Write' >> WriteToText(known_args.output)
File "/Users/stefan/workspace/biodiversity/.env/lib/python3.8/site-packages/apache_beam/pipeline.py", line 585, in __exit__
self.result = self.run()
File "/Users/stefan/workspace/biodiversity/.env/lib/python3.8/site-packages/apache_beam/pipeline.py", line 564, in run
return self.runner.run_pipeline(self, self._options)
File "/Users/stefan/workspace/biodiversity/.env/lib/python3.8/site-packages/apache_beam/runners/portability/portable_runner.py", line 438, in run_pipeline
job_service_handle = self.create_job_service(options)
File "/Users/stefan/workspace/biodiversity/.env/lib/python3.8/site-packages/apache_beam/runners/portability/portable_runner.py", line 317, in create_job_service
return self.create_job_service_handle(server.start(), options)
File "/Users/stefan/workspace/biodiversity/.env/lib/python3.8/site-packages/apache_beam/runners/portability/job_server.py", line 54, in start
grpc.channel_ready_future(channel).result(timeout=self._timeout)
File "/Users/stefan/workspace/biodiversity/.env/lib/python3.8/site-packages/grpc/_utilities.py", line 140, in result
self._block(timeout)
File "/Users/stefan/workspace/biodiversity/.env/lib/python3.8/site-packages/grpc/_utilities.py", line 86, in _block
raise grpc.FutureTimeoutError()
grpc.FutureTimeoutError
Any idea what's going on? Thank you for help. I also opened a bug regarding this issue here: https://issues.apache.org/jira/browse/BEAM-12657
The cluster is started from a docker container. You have to publish the ports so that the Python code executed on the host can access the port.
See https://ci.apache.org/projects/flink/flink-docs-release-1.13/docs/deployment/resource-providers/standalone/docker/ for the --publish option used in the docker run cmd.

Wagtailtrans 2.2 install fails

I've read all the tutorials for setting up wagtailtrans 2.2.
I set the languages in my base.py according to the tutorials. I cannot install wagtailtrans. I get error output about Pillow.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/2f/rfv6v0056c58r9w83rzw30n00000gn/T/pip-install-yn4w0un0/pillow_5e7e668306de465dbfb8730b888585f9/setup.py", line 918, in <module>
raise RequiredDependencyException(msg)
__main__.RequiredDependencyException:
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
I tried to reinstall Pillow according to their docs and reinstall wagtailtrans but it doesn't work. The error doesn't mention anything about wagtailtrans but when I go to makemigrations I get the error ModuleNotFoundError: No module named 'wagtailtrans'
I haven't found anything online about this so any help would be most appreciated. Sorry if this is a N00b question
If you're on a Mac, install Xcode tools, amongst other useful libraries, it will also bring the missing zlib. To install Xcode tools, run the following command in a terminal:
xcode-select --install

Pyflink : 'JavaPackage' object is not callable

When I run a Python file in Flink CLI using the following code:
python3 word_count.py
I got the error like this:
Traceback (most recent call last):
File "word_count.py", line 79, in <module>
word_count()
File "word_count.py", line 37, in word_count
t_config = TableConfig()
File "/usr/local/lib/python3.7/dist-packages/pyflink/table/table_config.py", line 49, in __init__
gateway = get_gateway()
File "/usr/local/lib/python3.7/dist-packages/pyflink/java_gateway.py", line 68, in get_gateway
callback_server_listening_address, callback_server_listening_port)
TypeError: 'JavaPackage' object is not callable
And I changed the way to run this Python file:
./bin/flink run --python3 /opt/flink/examples/python/table/batch/word_count.py
I got another error :
Could not build the program from JAR file.
Use the help option (-h or --help) to get help on the command.
Didn't figure out the first question but solved the second one.
The command within --python3 caused the error.
The official Pyflink command is
./bin/flink run -py word_count.py
Since there is only Python3 in my docker, I soft linked Python3 to Python using :
ln -s /usr/bin/python3 /usr/bin/python
And then the official Pyflink command works. You can see the completed job through Flink Web UI.
The default is to use the python interpreter on the machine to compile pyflink jobs, you can change it through python.client.executable.

Google Cloud Function - AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'

I'm using Appengine cron job to schedule cloud function and when I deploy and try to run a job, getting below error. Any idea what could be wrong here? Followed steps from [here][1]
(/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~zion-hymns/20180222t221057.407849847593018575/main.py", line 18, in <module>
import pubsub_utils
File "/base/data/home/apps/s~zion-hymns/20180222t221057.407849847593018575/pubsub_utils.py", line 24, in <module>
import oauth2client.contrib.appengine as gae_oauth2client
File "./lib/oauth2client/contrib/appengine.py", line 36, in <module>
from oauth2client import client
File "./lib/oauth2client/client.py", line 39, in <module>
from oauth2client import transport
File "./lib/oauth2client/transport.py", line 255, in <module>
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
AttributeError: 'module' object has no attribute 'DEFAULT_MAX_REDIRECTS'
[1]: https://firebase.googleblog.com/2017/03/how-to-schedule-cron-jobs-with-cloud.html?utm_campaign=culture_education_functions_en_06-29-17&utm_source=Firebase&utm_medium=yt-desc
Seems that I found the problem. Which version of Python your pip is using? In my case it was 3.6 despite the fact that the Python itself was 2.7
So the problem was that pip downloaded a Python 3.6 syntax version of httplib2, it was uploaded to the Google App Engine, which use Python 2.7. It tried to load in the module and fail miserably.
Try this :
Check the vesionn of your pip with :
pip -V
If you see some thing like pip 9.0.1 from /bla/bla/lib/python3.6/site-packages (python 3.6) then continue
Install pip for python 2.7 (it should be in the Python2.7 installation pachage under bin folder)
Remove old lib folder in your project
Run pip install -t lib -r requirements.txt (make sure that this pip is the right 2.7 version)
Deploy
By doing that you are using the right version of the lib and it should be working.
Hope it will help.

Installing packages which downloads files in Ubuntu 14.04

I am trying to install following packages in Ubuntu 14.04 but getting the following error:
ttf-mscorefonts-installer: downloading
http://downloads.sourceforge.net/corefonts/andale32.exe
Traceback (most recent call last):
File "/usr/lib/update-notifier/package-data-downloader", line 239, in
process_download_requests
dest_file = urllib.urlretrieve(files[i])[0]
File "/usr/lib/python2.7/urllib.py", line 94, in urlretrieve
return _urlopener.retrieve(url, filename, reporthook, data)
File "/usr/lib/python2.7/urllib.py", line 240, in retrieve
fp = self.open(url, data)
File "/usr/lib/python2.7/urllib.py", line 208, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 345, in open_http
h.endheaders(data)
File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 791, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 772, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
IOError: [Errno socket error] [Errno -2] Name or service not known
Processing triggers for fontconfig (2.11.0-0ubuntu4.1) ...
Setting up ttf-mscorefonts-installer (3.4+nmu1ubuntu1) ...
I am working behind a proxy server but proxy settings are working fine for all other package installations. I am also getting this same error when installing flashplugin-installer. I have checked the environment variables i.e http_proxy, https_proxy and ftp_proxy and they are set with appropriate values.
I had this error with Mint 17 and it seems to occur in Ubuntu 14.04. It's a known bug (see here and here).
What I did to solve was:
sudo su
if you're proxy requires authentication:
export http_proxy=http://<username>:<password>#<your_proxy>:<proxy_port>
if i doesn't require authentication:
export http_proxy=http://<your_proxy>:<proxy_port>
and finally install the package like you would normally do
apt-get install <package_to_install>
or reinstall the package in case you already had install it
apt-get install --reinstall <package_to_install>
I tested with ttf-mscorefonts-installer but I guess that it should also work with flashplugin-installer.

Resources