#VSCode – Installing Visual Studio Code in a #RaspberryPi, a couple of lessons learned – @code

Hi!

Now that I have my amazing Raspberry Pi 4 with 4GB RAM, it’s time to see how serious the device is. So, I decided to install and use some developers’ tools in the RPi. My dev list will be something like this

  • Python
  • Some ML and AI Python packages
  • GIT
  • Arduino
  • Visual Studio Code

It’s been a while since I installed VSCode in the device. The last time I did this, I needed to download the code from GitHub and compile the tool in the Raspberry Pi. As far as I remember this was a +25 min process.

Lucky for us the process can now be much simpler, thanks to Headmelted (see references). Now, we only need a single command to install VSCode:

. <( wget -O -
https://code.headmelted.com/installers/apt.sh )

Install process started! Or Maybe not because I found this amazing GPG error

python error installing visual studio code in raspberry pi
pi@rpidev3:~ $ curl -L https://code.headmelted.com/installers/apt.sh | sudo bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2349 0 2349 0 0 19739 0 --:--:-- --:--:-- --:--:-- 19906
Detecting architecture…
Ensuring curl is installed
Reading package lists… Done
Building dependency tree
Reading state information… Done
curl is already the newest version (7.64.0-4).
The following packages were automatically installed and are no longer required:
python3-pyperclip python3-thonny rpi.gpio-common
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Architecture detected as armv7l…
Retrieving GPG key headmelted
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
gpg: no valid OpenPGP data found.
Removing any previous entry to headmelted repository
Installing [headmelted] repository…
Updating APT cache…
Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
Hit:2 http://archive.raspberrypi.org/debian buster InRelease
Get:3 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease [23.4 kB]
Err:3 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8
Reading package lists…
W: GPG error: https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8
E: The repository 'https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease' is not signed.
Done!
Repository install complete.
Installing Visual Studio Code from [stretch]…
Reading package lists… Done
E: The value 'stretch' is invalid for APT::Default-Release as such a release is not available in the sources
Visual Studio Code install failed.

There a public GPG key used to verify the package and the SH script somehow does not download it (I think the ARM RPI version is still not defined). So, before the previous command, I need to run this command

wget https://packagecloud.io/headmelted/codebuilds/gpgkey -O
- | sudo apt-key add –

Now we have Visual Studio Code installed!

raspberry pi visual studio code installed

But, yes another but, you may note that the tool open and display a black window. Again, I need to go deeper on the details, but the latest version does not work well. There is some context information on GitHub (see references), and the proposed solution is to rollback to a previous version

sudo apt-get install code-oss=1.29.0-1539702286

And we also need to disable the automatic updates on this tool

sudo apt-mark hold code-oss

And now, yes, we got a fully functional Visual Studio Code in our Raspberry Pi!

Happy Coding!

Greetings @ Toronto

El Bruno

References

Advertisements

#RaspberryPi – Running a #python script in a Python Virtual Environment on reboot / startup

Hi!

Adrian Rosebrock is a very smart person who has tons of great resources about Computer Vision in PyImageSearch.com. Most of them are with Python, and he also have some of them focused on how to perform CV using OpenCV in a Raspberry Pi.

In the post [Running a Python + OpenCV script on reboot, see resources] he explains how to automatically run a Python script when a Raspberry Pi starts. He uses python virtual environments, so the first 2 commands are focused on to load the virtual env. Then, move to the app folder and run the python script.

source ~/.profile
workon cv
cd /home/pi/pi-face-recognition
python startup.py

Something like this:

python source and cv on raspberry pi.

The suggested approach consists on create a Schell Script [.sh file] with these lines and add them to the auto start. However, once you create the file and test it, there seems to be an issue with the Source command.

python source not working on SH file

Ok, so no source command in an SH file. I started to think on install all my python dependencies directly in the main user, however the idea of working with virtual environments is very useful for me. It was to read online about Linux, python and more.

Note: Before moving forward, I may need to add some context. I need to run my python script in a Terminal. My device will always auto-start with a 3.5 inches touch screen and a camera, so I need some GUI loaded.

This is an excellent article on how to add actions to the Raspberry Pi start-up [How to Execute a Script at Startup on the Raspberry Pi, see resources]. So I added my SH file here and it didn’t work and I need to figure out how to load a virtual environment and run a python script.

After a couple of tests, I realized that all the files I need are part of the virtual env location in the device.

raspberry pi python folder for virtual envs

So, I only need to add the full path to my command to make it work without the and [workon] command. My complete command will became:

/home/pi/.virtualenvs/cv/bin/python /home/pi/pi-face-recognition/startup.py

So, I edited my autostart file adding this command

raspberry pi auto start file launching python script with a virtual env

And done! My python script running on a python virtual environment on the device startup is working!

Happy coding!

Greetings @ Toronto

El Bruno

Resources

#Python – How to create a Virtual Environment in #Windows10 (Easy one, and brain backup!)

Hi!

Quick post today, and mostly a reminder on how to create a Virtual Environment in Python in Windows 10. I’ve been doing this mostly in my Mac and my Raspberry Pi, and I always forget how to do this on Windows, so … I’ll write this post to have this

Install Python3.

Download the installers from the official Python source (see references). I usually install it on the root of my C: hard drive and name it with the version. In example: c:\Python37_64 folder.

Remember to also add this folder and the Scripts folder to the Environment Variables.

Note: Once you start to install tools which uses Python, your OS becomes a nightmare. You will have your own installed python, the version installed with Visual Studio, the one with Visual Studio Code, another one for Anaconda.

I’m not sure if this is a best practice or not, but I usually remove all the other versions and keep mines in the root of the C: drive.

Ok, let’s go on.

For a new virtual environment named “testEnv”, open a command prompt and navigate to the python folder. Then run the command

python -m virtualenv testEnv

After a couple of seconds, the virtual Environment will be installed, and you can use it by run the [activate.bat] script. In this example

  • The virtual environment will be created at [c:\Python37_64\testEnv]
  • The virtual environment activate script will be at [c:\Python37_64\testEnv\Scripts\activate.bat]

So the full command sequence is similar to this one

Now you have your virtual environment up and running and you may want to start to add your own packages or tools. Like in example: Numpy or to list the installed packages

Finally, you may leave the virtual environment with the command

deactivate

Happy Coding!

Greetings @ Toronto

El Bruno

Resources

#Windows10 – Using W10 Mobile Hotspot on Holidays

Hi!

Big off-topic for today’s post. However, I think it’s worth sharing these workarounds, hoping they’ll be useful for someone else. Well, before starting a bit of context:

Last week we went on vacation with family and friends to the Caribbean. In general, having internet connectivity is not a priority. However, one of the Free Wifi policies was: Internet access via WiFi was free, but you could only authenticate 2 Devices per room.

In a family of 4 people, where each one has at least one device that requires an internet connection, I did not close the numbers. We did not need to be connected all 4 of us all day, but there were times where we needed at least 3 devices connected.

After investigating for a while, I realized that the filter of devices connected by room does not include ranges of IPs or Mac Address, so the Windows 10 option to create a Mobile Hotspot was an option. 3 clicks later we were already 4 devices connected to the internet, the test had been a success!

 

I3

The Bing search engine details the step by step necessary to enable a Mobile Hotspot in [ Use your PC as Mobile Hotspot ].

Open Mobile Hotspot Settings

Note: Until now I have only used MH as a hotfix in Hololens demos, it also works on holidays!

Happy coding!

Greetings @ Toronto

El Bruno

#Windows10 – Usando W10 Mobile Hotspot en vacaciones

Buenas!

Menudo off-topic me marco hoy, pero vale la pena compartir estos workarounds, esperando que le sirvan a alguien. Pues bien, antes de comenzar un poco de contexto:

La semana pasada nos fuimos de vacaciones con familia y amigos al Caribe. Por lo general, tener conectividad a internet no es una de las prioridades, sin embargo, una de las políticas de Free Wifi me llamo la atención (hacía mucho que no la veía). El acceso a internet vía WiFi era gratis, pero solo podías autenticar a 2 Devices por habitación.

En una familia de 4 personas, donde cada uno tiene mínimo un device que requiere conexión a internet, no me cerraban los números. El detalle es que no necesitábamos estar conectados todo el día las 4 personas, pero había momentos donde necesitábamos al menos 3 devices conectados.

Despues de investigar un rato, me di cuenta de que el filtro de devices conectados por habitación no incluye rangos de IPs ni Mac Address, con lo que la opción de Windows 10 de crear un Mobile Hotspot era una opción. 3 clicks después ya estábamos 4 devices conectados a internet, la prueba había sido todo un éxito !!!

I3

El buscador de Bing te detalla el paso a paso necesario para habilitar un Mobile Hotspot en [ Use your PC as Mobile Hotspot ].

Open Mobile Hotspot Settings

Nota: Hasta ahora solo habia usado MH como hotfix en demos de Hololens, tambien sirve en vacaciones!

Happy coding!

Saludos @ Toronto

El Bruno

#HowTo – Add #360 Photos in posts in wordpress.org

Hi!

A few months ago I get, as a family present, a Ricoh Theta SC 360 camera. Mostly, for personal use and the truth is that I have a great time with this new device. Compared with other models of the Ricoh Theta range, the main difference is that this model does not support Live Streaming. If at any time I see that this is a necessity, then I will evaluate again what options there are in the market.

Currently, one of the activities where I use the camera is when I participate in an technical event. If there is time and everyone is in ok with this, I activate the [Interval Shooting] mode and from a fixed position I capture a 360 photo every N minutes. The result is a very pleasant Time Lapse.

When sharing photos 360, the only platform on social networks that is really prepared for these contents is Facebook. Twitter, Instagram and the others are several steps behind. And, as always, wordpress.org is a world apart.

Important: My blog is on wordpress.org, so what I write in this post only applies to similar scenarios.

Well, when you add a 360 photo to WordPress, you have something similar to the next picture

R0010184

It is not what we expect, much less in a 360 photo. The official solution is to use a Plugin to view photos or videos in 360-degree format. In the Marketplace of plugins there are many free and paid options.

This is simple when you manage your own WP, in my case, I need to update a plan to something that is 10 times more expensive than what I currently pay

I2

After doing some research about it, I’ve found a WordPress post of the year 2016 where they commented that Out-Of-The-Box WordPress will support 360 content. The syntax that we should use is quite simple

I3

Applying this scheme my initial image changes a lot and for the better. It can be seen in 360 mode

Happy coding!

Greetings @ Burlington

El Bruno

References

#HowTo – Agregando imágenes #360 en nuestros posts en wordpress.org

Buenas!

Hace unos meses que tengo en mis manos una cámara 360 Ricoh Theta SC para uso personal y la verdad es que me lo paso genial. Comparadas con otros modelos de la gama Ricoh Theta, la principal diferencia es que este modelo no soporta Live Streaming. Si en algún momento veo que esto es una necesidad, pues evaluare nuevamente que opciones hay en el mercado.

Actualmente, una de las actividades donde utilizo la cámara es cuando participo en algún evento. Si hay tiempo y todos están de acuerdo activo el modo [Interval Shooting] y desde una posición fija capturo una foto 360 cada N minutos. El resultado es un Time Lapse bastante agradable.

Al momento de compartir las fotos 360, la única plataforma en redes sociales que realmente está preparada para estos contenidos es Facebook. Twitter, Instagram y los demás, están varios pasos por detrás. Y, como siempre, wordpress.org es un mundo aparte.

Importante: mi blog está en wordpress.org. Con lo que lo que escribo en este post solo aplica para escenarios similares.

Pues bien, al momento de agregar una foto 360 a WordPress el resultado que tenemos de la misma es el siguiente

R0010184

No es lo que esperamos ni mucho menos en una foto 360. La solución oficial es utilizar algún Plugin para visualizar fotos o videos en formato 360 grados. En el Marketplace de plugins hay muchas opciones gratis y de pago.

Esto es simple cuando gestionas tu propio WP, en mi caso, necesito actualizar un plan a algo que es 10 veces mas caro que lo que actualmente pago

I2

Después de investigar un poco al respecto, me encontré con un anuncio de WordPress del año 2016 donde comentaban que Out-Of-The-Box WordPress soportara contenido 360. La sintaxis que debemos utilizar es bastante simple

I3

Aplicando este esquema mi imagen inicial cambia mucho y para mejor. La misma se puede ver asi en modo 360

Happy coding!

Saludos @ Burlington

El Bruno

References

#Quantum – Information about Simulators on Microsoft Quantum Development Kit (Do you have 16 TB RAM?)

36626328074_f9372acb8f_b

Hi!

Today is Microsoft Tech Summit Day in Toronto, so I will write a quick post about simulators on Microsoft Quantum Development Kit.

I’m sure you already downloaded and installed he tools to work with Q#. So you see that when we created a Q# project, we can see that we have a Q# file and another file in a standard programming language, for example, C#. The approach Microsoft has taken in this case is based on a coprocessor scheme. It is very similar to how a GPU or a FPGA works. Once a GPU is programmed, we can call that code from external environments, like a CPU.

We still don’t have access to Quantum Computers (sad emoticon here), however Microsoft Quantum Development Kit allows us to have a 1st approach, by using simulators to work with Q#. There are two classes in [Microsoft.Quantum. Simulation.Simulators] which allow us to run simulators.

In this scenarios we can work with a finite number of Qubits. The main restriction we have on the amount of Qubits is given by the Hardware characteristics of our development machine.

Clipboard02

Let’s do some numbers. To simulate 30 Qubits, we need 16 GB of RAM. However, if we want to add a new single Qubit, I mean work with 31 Qubits, we have to duplicate the RAM: 32 GB of RAM. If we move to the order of 40 Qubits, we have to think about 16 of RAM. That’s why, One of the simulator’s options is to use Azure’s ability for simulations that require 40 Qubits or more.

Finally, I have to comment that, Q# allows us to have a high level of abstraction to work with Quantum Computing models. And, while at this time we use simulators for the execution of the Q# algorithms, in the near future we will be able to execute these algorithms directly in a Quantum Computer.

Happy QCoding!

Greetings @ Microsoft Tech Summit

El Bruno

References

Images

#Quantum – Capacidades e información de los emuladores en Microsoft Quantum Development Kit (tienes 16TB de RAM?)

36626328074_f9372acb8f_b

Buenas!

Hoy es día de Microsoft Tech Summit en Toronto, así que aprovechare para dejar un par de datos sobre los emuladores de Microsoft Quantum Development Kit.

Cuando creamos un proyecto de Q#, podemos ver que en el mismo tenemos un archivo en el Q # y el otro en un lenguaje de programación estándar, por ejemplo, C#. El enfoque que ha tomado Microsoft en este caso está basado en un esquema de coprocesador. Es muy parecido a cómo se programa una GPU o FPGA. Una vez programadas, podemos llamar ese código desde entornos externos, como una CPU.

Como todavía no tenemos acceso a Quantum Computers físicos, Microsoft Quantum Development Kit nos permite utilizar emuladores para trabajar con Q#. Hay dos clases en [Microsoft.Quantum.Simulation.Simulators] que nos permiten ejecutar emuladores, donde podemos trabajar con un numero finito de Qubits. La principal restricción que tenemos sobre la cantidad de Qubits esta dada por las características de Hardware del equipo de desarrollo.

Clipboard02

Así para simular 30 Qubits, necesitamos 16 GB de RAM. Sin embargo, si queremos agregar un nuevo Qubit, es decir trabajar con 31 Qubits tenemos que duplicar la RAM: 32 GB de RAM. Si hablamos de 40 Qubits, tenemos que pensar en 16TB de RAM. Es por esto que, una de las opciones del simulador es utilizar la capacidad de Azure para las simulaciones que requieran 40 Qubits o más.

Por último, tengo que comentar que, Q# nos permite tener un nivel abstracción alto para trabajar con modelos de Quantum Computing. Y, si bien, en este momento utilizamos emuladores para la ejecución de los algoritmos que creamos en Q#, en un futuro cercano podremos ejecutar estos algoritmos directamente en una Quantum Computer.

Happy QCoding!

Saludos @ Microsoft Tech Summit

El Bruno

References

Images

#VS2017 – Hello QWorld using Microsoft #Quantum Development Kit (fix to build the project) [Updated]

Hi!

Today is a special day, from this moment on, 98% of what I learned at the university is no longer useful for me. I will no longer use binary states in my computing devices, now is time to work with Quantum States.

In fact, there is still a long way to make this a reality. However, now we can start to learn some of the basis of Quantum Computing using Visual Studio 2017. The name of the language also gives honor to the elements that we already know: Q# (Q Sharp).

Note: I know, surely some freak will say that the IDE is very heavy, slow, etc. The answer is always: your opinion is important I am very interested, please tell me more!

So, now we can download Microsoft Quantum Development Kit and create our first [Hello QWorld] to understand the new logic gates model, how to work with Qubits, and much more of the exciting world of quantum Computing.

The Microsoft Quantum DevKit we have an excellent step by step to build a Console App which allows us to work with 2 Qubits and also show the entaglement between them. Well, the 1st steps are very encouraging.

We start installing a package to have the Q# DevKit in Visual Studio 2017

I1

Then we will be able to create Q # applications, as well as libraries and test projects.

I2

And that’s it, this is the end of the fun, it’s fixing configuration error time! We have a very good looking error when trying to build the project:

I4

This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.Quantum.Development.Kit.0.1.1712.901-preview\build\Microsoft.Quantum.Development.Kit.props

[Update: Microsoft Quantum have already published the packages in Nuget.org, so the build will work fine the 1st time. https://www.nuget.org/packages?q=Microsoft.Quantum]

I first thought that this was related to the NuGet packages, maybe these two were not the right ones. The project template of Q # adds these 2 packages

  • Microsoft.Quantum.Canon
  • Microsoft.Quantum.Development.Kit

I3

I ended up spending a lot of time thinking that the error was that these packages were not available in NuGet. (When I write this both packages are still not available)

So, I took some smart time and I read the error. The problem is that the project can not process any of the Q# compilation targets. If you wonder what imaginary beat are related to the Q# compilation targets? Let me tell you that the Q# source code files uses an .qs extension. and are processed with a special compiler. (A Quantum compiler!)

I5

Let me get back to my story, in every step I lose the thread. The problem is that the project that is created can not find any of the libraries or targets of Microsoft.Quantun. And since they are not yet published in nuget.org, it’s time to fix this in the old fashion way.

If we edit the project file of the Q# App, we will see that the location where the Microsoft.Quantum.* elements are located. is  [..\packages\Microsoft.Quantum…]

I6

However, the project template adds the [packages\Microsoft.Quantum…] folder inside the project folder.

I7

You can imagine the solution, copy/move the folder [packages] to the top folder of the project. Now you can compile your project and go ahead with the tutorial!

I8

In next posts I will write a little bit about the capabilities of the Microsoft Quantum Development Kit. Although the first thing was to have the ability to finish the Hello Q World tutorial.

Happy QCoding!

Greetings @ Burlington

El Bruno

References