Python Illegal instruction on Raspberry Pi Zero - python

When I try to run a python script I get Illegal instruction and that's it, it doesn't give any more details so I have no idea what's going on, is there a way to find out what is causing the Illegal instruction error?
Also, I run the code using sudo I don't get any output, the program just exits.
UPDATE:
The script I'm running is the simple-agent script from bluez:
https://github.com/pauloborges/bluez/blob/master/test/simple-agent
Also, I ran line by line like #buratino said and I got the error in the second line:
from gi.repository import GObject

Like #Notlikethat said, the Illegal instruction error happens when the code being executed was compiled for a different architecture, Raspberry Pi uses ARM.
That said, I found out that GObject seemed to be causing the problem. Anyway, I uninstalled every bluetooth related package I had installed and reinstall them using the raspbian repository and now the Illegal instruction is gone and the script executes correctly.
Why did this happen? Well, I have a Raspberry Pi Zero which means I don't have an Ethernet port, before I bought a WiFi dongle I installed a few packages by downloading them on my computer and storing the .deb in the SD card, of course this means I have to manually check that I'm downloading the right version of the package, I must've messed up in one of them.
Lesson learned, never try to manually install packages, let apt-get do all the work!

Related

Why am I getting "Importing the numpy C-extensions failed" on some systems, but not all systems running python script?

I built a python based program. Prior to this project, I have not run a python program from an exe, but I needed to run this project from an exe on a Windows 10 machine. Using pyinstaller I created and tested the final project without issue, but as soon as I set it up on another computer, it returned an "Importing the numpy C-extensions failed" error message. This seemed weird because I did not receive this error on my computer. So I created a clean installation on a VM, and no error. The other system has python installed, but the version is the same as the one I am using on my computer. Regardless of the installed python version, I thought pyinstaller created a stand-alone python environment.
Is there something I should check or compare between the two systems?
Additionally, my system and the VM started the program without a Windows Defender popup, but the problematic system shows a "Windows protected your PC" popup that needs to be bypassed. Is there a Windows defender setting that might be causing this issue?
Thank you to anyone who has information on this issue. I am fairly new to Python and could use any positive advice available.
I have run the program on a clean VM, with no issues. After some research, I tried uninstalling and reinstalling the numpy on the problematic system, but the issue persists. I cannot figure out what is casuing the error on one system but not any others.

Running python script with tkinter on iphone

not sure if possible, maybe someone has sucess
I have a little python script for my university exams and it will be great to show execution on the mobile. It uses tkinter for the GUI (I know, probably not the best, but it has been done like this)
I have it running on Android (not my phone) within Pydroid3 without any problem, but I can not replicate in iphone
so far i have tried Python3IDE and CodeSnackIDE (among others that can not get even python to work)
Python3IDE
as it seems terminal do not support sudo, neither apt-get, no change to install tkinter
CodeSnackIDE
successfully installed tkinter, using the instructions as:
https://docs.codesnack-ide.com/Python-using-Pipenv-5a77effdbad44930b7927a37e25d4c45
(after pipenv run sudo apt-get install python3-tk)
but i would say that the running is remote, and do not have display, can it be?
trying using tkinter raise the error:
couldn't connect to display :1
and after running export DISPLAY=unix$DISPLAY
(as local machine _tkinter.TclError: couldn't connect to display ":0")
couldn't connect to display unix:1
Am I trying something never done before?
or something not meant to be done ... :_(
I know there is posts like:
Is it possible to use Tkinter to create an app for Android or iOS?
and not sure if this fully applies

gpiozero.exc.PinPWMUnsupported: PWM is not supported on pin GPIO7 (Raspberry Pi 4B)

I am working on my first Raspberry Pi project while following a course for creating a line-following robot. This is the course. I followed all the instructions and connected the pins as it describes but when I run the code on the Raspberry Pi OS it throws an error:
gpiozero.exc.PinPWMUnsupported: PWM is not supported on pin GPIO7
This is the code:
from gpiozero import Robot
from time import sleep
my_robot = Robot(left=(7,8), right=(9,10))
my_robot.forward()
sleep(1)
my_robot.stop()
I tried to search for solutions and checked the official documentation but it hasn't been helpful. How can I fix this?
The likely reason for this error is that the user has installed gpiozero into a virtual environment without installing a pin library. gpiozero's built-in pin interface does not support PWM. You need to install RPi.GPIO to get the normal experience:
pip install gpiozero rpi-gpio
This is mentioned in the docs: https://gpiozero.readthedocs.io/en/stable/faq.html#why-do-i-get-pinfactoryfallback-warnings-when-i-import-gpiozero
I had the same problem with gpiozero's CamJamKitRobot and Robot classes when trying to run it in a pipenv (same issue may occur with a virtual env, but I have not tried). Running the script outside of the pipenv (therefore just using the system installed pip packages) resolved the issue for me.
After many checks, it resulted that the GPIO pins and the software were ok. The motors were connected to a L289N Driver Motor module, which wasn't getting enough power from the batteries and this was the cause of the error. In case someone has the same or similar hardware connections and faces this issue, check if the L289N module is powered on (it should turn on the red LED that's on the module).
I was following the guide on https://www.raspberrypi-spy.co.uk/2018/02/basic-servo-use-with-the-raspberry-pi/ with Micro Servo WS-SG90 and Raspberry Pi 3B+ and used the gpiozero Python library and ran into the same exception. In my case this was caused by running the program as non-root user. Running the program with sudo made the servo turn. The other alternative would be to use PiGPIOFactory with pigpiod which does not require to run the program with elevated privileges.

Using Pexpect with Python 3

After hours of research I have broken down to posting. I am trying to use the Pexpect module with python 3, which I am led to believe is possible from the document page which does say it will run with python 3.2.
Things I have tried: I have tried many different ways of installing including downloading the source and running the command sudo python3 setup.py install. I have also tried installing it with pip and *easy_install* which is what the documentation suggest. It seems that everything goes off with out a hitch until I attempt to import the module in the pyshell. When I type import pexpect I get the error:
class spawn(object):
File "/usr/local/lib/python3.2/dist-packages/pexpect/init.py", line 286, in spawn
write_to_stdout = sys.stdout.buffer.write
AttributeError: 'PseudoFile' object has no attribute 'buffer'
I have also tried googleing the error with no luck. And I have tried using python 2.7 and it works fine. I have tried on multiple debian based operating systems: Ubuntu 12.04 and Kali with the same results.
I feel like there is something obvious I am missing, but I just don't see it. Any points in the right direction Or helping me understand the error message would be much appreciated!
There was a bug in Pexpect 3.0 which stopped it working if sys.stdout was replaced before it was imported. It looks like IDLE replaces stdout, so as you've found, it doesn't work in IDLE & Python 3.
The bug has now been fixed. I'll try to get a new version of Pexpect out in the next few days, and then you'll be able to use it from IDLE.

Problems building node.js on Cygwin, please help

I'm trying to get node.js running on Windows 7. I have no experience with Linux so I've just been blindly following instructions from tutorials I've found, but I'm still unable to build node.js.
What I did:
Install Cygwin - the entirety
Attempt to build node.js
This is the error I first got:
I then followed the commands of two other similar sites and they all resulted in this error (could getting several version of node have caused me more problems? I'm completely clueless on this).
I read somewhere that the Windows version of Python could be causing the problem so I uninstalled my Python 2.7 and added C:\cygwin\bin to the PATH.
That still didn't work and I read somewhere else that I'm supposed to rebaseall so I tried that, but I also got an error for that:
That's where I'm at now. Have any steps I've taken exacerbated the situation?
Add -e '/\/sys-root\/mingw\/bin/d' at line 110 in /bin/rebaseall file.
Then re-run rebaseall -v and you shouldn't get the error anymore.
See this pretty helpful blog posting - Node on CygWin doesn't work for Node v0.2.5. Use the latest v0.4.0 version instead.
Also consider the post's recommendation of compiling against MinGW instead of in CygWin.
First of all, why did you check out such an old release v0.2.5? When I did it a few weeks ago I just took the latest and ended up with 0.5.0pre, but it would also be reasonable to specify v0.4.3. For instance, type git clone git://github.com/joyent/node.git to download node, and then:
cd node
./configure
make install
Secondly, do not rebase by running ash from the CYGWIN shell. Instead, shutdown all Cygwin processes, then use Windows explorer to open the ash.exe binary. Since I have a Windows 7 system without node.js, I decided to follow my instructions and build. Not so easy. I ran into some wierd dll issues that all went away when I ran ./rebaseall followed by ./perlrebase from the ash prompt. It seems that rebaseall is not sufficient anymore.
Thirdly, there is a message that makes it sound like you don't have a C compiler. Some googling will lead you to sites telling which Cygwin packages you need, but at minimum install the g++ compiler and that should pull in C as a dependency.
When I did this I simply ran configure and every time there was an error, installed one more Cygwin package to supply the missing piece. Even OpenSSL is available.
What I just found is remove the windows based install of Python. After uninstalling this, everything is peachy.
I like cygwin a lot -- but recent releases have become pretty unreliable. Some packages just wont build, and some "standard" apps dont work e.g. gvim's "save as" bombs out on my installation.
A possible solution would be run one of the better Linux distributions (ubuntu, fedora, suse etc.) either as a virtual machine or a dual boot setup and do the build inside linux.

Categories

Resources