Connect Python Backend on Windows with Ikea Tradfri - python

I'm trying to connect my python Backend with Ikeas's Tradfri to control it from my own app.
I found that for this communication I need DTLSSocket and libcoap, but according to this repo here (https://github.com/ggravlingen/pytradfri/issues/97) there are some major problems installing these libs on windows.
I tried it myself and it's still not working. Installing DTLSSocket on Windows results in:
ERROR: Failed building wheel for DTLSSocket
Of course I could use a VM or the WSL service to build a linux environment, but that's actually not what I want.
Is anyone of you aware of another solution how to connect to the tradfri gateway or knows how to install the required libs on Windows?
Thanks!

pip install conda
Then try again.

Related

Problem using OpenCV in WSL, when opening windows

I am using WSL, and when running some Python code with OpenCV that needs to open a different window, it throws an error.
This is the code:
import cv2 as cv
image = cv.imread("images/pic.jpg")
cv.imshow(0)
cv.waitKey(0)
And this is the error I get
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/user/.local/lib/python3.8/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this
problem.
Available platform plugins are: xcb.
Aborted (core dumped)
I faced a similar problem. As recommended by most people, I tried putting a symbolic link and installing new packages. I changed QT_PLUGIN_PATH, I exported AT_DEBUG_PLUGINS=1 also. Those options did not seem to work for me. I was on Windows 10 with WSL2, running OpenCV cv2.image which was not showing. Errors were said to be qt related (as stated by #josh merrian).
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/user/.local/lib/python3.8/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this
problem.
Available platform plugins are: xcb.
Aborted (core dumped)
Try running xeyes.
sudo apt-get install x11-apps
xeyes
Does it run? If not you may be having the same problem I had.
In my case, I learnt that in WSL2 we need to have an Xserver to deploy Ubuntu oriented graphical applications. I read about Xming and also VcSrv. I tried VcSrv and it worked for me.
See: https://www.stat.ipb.ac.id/agusms/index.php/2019/01/15/how-to-run-graphical-linux-applications-on-bash-on-ubuntu-on-windows-10/
Hope this helps somebody out there. Goodluck.
You need to enable your environment for GUI application on WSL.
Using the GUI for enabling Windows features
Open the Start Menu and search Turn Windows features on or off
Select Windows Subsystem for Linux
Click OK
Restart your computer when prompted
upgrade OpenCV, with the following command using pip
pip3 install --upgrade opencv-python==4.3.0.36

Firebase on AWS Lambda Import Error

I am trying to connect Firebase with an AWS Lambda. I am using their firebase-admin sdk. I have installed and created the dependancy package as described here. But I am getting this error on Lambda:
Unable to import module 'index':
Failed to import the Cloud Firestore library for Python.
Make sure to install the "google-cloud-firestore" module.
I have previously also tried setting up a similar function using node.js but I received an error message because GRPC was not configured. I think that this error message might be stemming from that same problem. I don't know how to fix this. I have tried:
pip install grpcio -t path/to/...
and installing google-cloud-firestore, but neither fixed the problem. When I run the code from my terminal, I get no errors.
Part of the problem here is that grpcio compiles a platform specific dynamic module: cygrpc.cpython-37m-darwin.so (in my case). According to this response you cannot import dynamic modules in a zip file: https://stackoverflow.com/a/58140801
Updating to python 3.8 fix this for me
As Alex DeBrie mentioned in his article on serverless.com,
The plugins section registers the plugin with the Framework. In the custom section, we tell the plugin to use Docker when installing packages with pip. It will use a Docker container that's similar to the Lambda environment so the compiled extensions will be compatible. You will need Docker installed for this to work.
Which means, the environment is different between Local and Lambda, so the compiled extensions would differ. If use a container to contain packages installed by pip, the container would mimic the environment of Lambda, then everything would run well.
If you use Serverless Frame work to deploy your Python app to AWS Lambda, add these lines to serverless.yml file:
...
plugins:
- serverless-python-requirements
...
custom:
pythonRequirements:
dockerizePip: non-linux
dockerImage: mlupin/docker-lambda:python3.9-build
...
then serverless-python-requirements would automatically open a Docker container based on mlupin/docker-lambda:python3.9-build image.
This container would mimic the Lamda environment, let pip install and compile everything in it. So the compiled extensions will be compatible.
This worked in my case. Hope this helps.

Manually installing pyodbc on Windows with firewall

I am trying to install pyodbc on my work machine which has a firewall. So I donwnloaded pyodbc-3.0.7.zip, and tried to install it manually with the following command:
pip install C:\Users\AppData\Local\Continuum\Anaconda\pkgs\pyodbc-3.0.7.zip
But it did not work. From searching around, if I want to continue on in this path, it looks like I need to compile the c++ source.
Is this the only way to go if I want to install pyodbc manually?
Select the appropriate exe for your CPU architecture from here. Once the executable is downloaded, an active network connection isn't needed.

Verify thread-safety MySQLdb (Python) prior to Trac installation

I'm trying to install Trac manually for the first time. I don't want to use a one-click-installer like Bitmani, I want to learn how to install Trac manually, so I'm following the instructions carefully. I'm installing it in a Windows localhost for now, before installing it in a Linux environment.
As I follow the instructions carefully, I needed to install Python+MySQLDb, and I read this:
thread-safety is important
(...) verify that it is thread-safe by calling MySQLdb.thread_safe() from a standalone Python script (i.e., not under Apache). If the stand-alone test reports that MySQLdb is indeed thread-safe (...)
I've just installed MySQLDb 1.2.4 and I'd like to verify this. I've Googled but I haven't found an example about this, and I have no idea about Python. How can I verify if I've got a thread-safe installation?
Run this command. If you get 1 in the output, your installation is threadsafe.
python -c "import MySQLdb ; print MySQLdb.thread_safe()"

Using opscode's omnibus installer in windows 7

I am working my way through a video tutorial at http://gettingstartedwithdjango.com/en/lessons/introduction-and-launch/
I am working on win7 and using git-bash for my terminal. I have installed the latest virtualbox - 4.2.12 and the latest vagrant - 1.22.
I tried to run vagrant up and got: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
creating Makefile
make
sh: 1: make: not found
Once of the answers given by jtimberman is:
The basebox you're using does not have the "build-essential" package installed by default, and it has a "[shell provisioner][1]" that installs the Chef gem into the default Ruby environment. Chef has a dependency on the JSON RubyGem, which itself has C extensions that must be compiled. This is what is looking for `make`.
To resolve this issue, I'd recommend using Opscode's "omnibus" [full stack installer for Chef][2]. This can be used by changing the shell provisioner line to:
config.vm.provision :shell, :inline => "curl -L https://opscode.com/chef/install.sh | bash"
The `[install.sh][3]` script simply inspects the VM to determine what its platform is so it can retrieve the proper URL from an S3 bucket. If you prefer you can use the constructed URL to download the .deb file directly:
https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/11.04/x86_64/chef_11.4.4-2.ubuntu.11.04_amd64.deb
And then install it:
dpkg -i chef_11.4.4-2.ubuntu.11.04_amd64.deb
I have not been able to get the first method to work and would like to try the second. would:
dpkg -i chef_11.4.4-2.ubuntu.11.04_amd64.deb
work on win7. If not how do I get this working in windows?
In order to compile native extensions in Windows, you must install the Ruby DevKit. Joshua's answer is valid for Debian-based systems.
An addition to sethvargo.
In addition to the Ruby DevKit, you also need the client library for your native software.
For example, in order to compile/install ruby-oci8 gem, you should have the Oracle Client installed on your computer as well.

Categories