Installed new python packages now get error when running Sim

4 posts / 0 new
Last post
Jamie
Jamie's picture
Installed new python packages now get error when running Sim

I was playing around with some image template matching instructions that I found on a few websites, and for some reason I thought it would be a great idea to just use the same Pi I use for my FormulaPi code testing. Long story short the instructions I followed required installing a few new packages. The image matching testing came out with some success, but I'm no longer able to run the simulator and get this error message:

Exception in thread Thread-7:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "./SimulationFull.py", line 254, in run
    if frame == None:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I went back to an earlier version of my code (the one submitted for the first challenge round) to confirm I hadn't made a mistake somewhere since the last time I knew it was working, but I got the same error message. So, it's definitely something that I installed for the template matching.

These are the commands I ran to install the new packages. Please DON'T RUN THEM!!

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo apt-get install python2.7-dev
sudo python -mpip install -U matplotlib

I suspect the downloaded python script to install PIP is the culprit as reading through the script I found it does quite a lot. It must have stepped on something it shouldn't have and overwritten it.

Just wondering if anyone has had something like this happen to them, and if you were able to recover. Or if you have any suggestions on how to fix this without rebuilding the sd card.

Jamie

Jon (not verified)
frame == None error

Can't say for sure but it looks similar to issues I've had with similar errors.
This might help?

# Instead of
if frame == None:
# try
if frame is None:

# Instead of
if frame != None:
# try
if frame is not None:

see also this post here:
https://www.formulapi.com/node/255

Hope that helps!

Arron Churchill
Arron Churchill's picture
Numpy version

Jon's comment above is spot on, the error itself can be fixed by using the is None syntax instead of == None.

The cause of the trouble is numpy. Older versions allowed arrays to be compared to None and would return False as expected. Newer versions they decided the syntax was ambiguous and instead the comparison causes an error.

As matplotlib relies on numpy I would suspect it has installed a newer version than we have, post the change in behaviour. It should be fixable by uninstalling the currently used version of numpy and then installing an older version of numpy instead.

From looking at some other notes I believe the correct version is 1.10.2, but I am away for the holidays so I cannot confirm that :)

Jamie
Jamie's picture
It worked

I removed the currently installed version of numpy and installed version 1.10.2 and it works again. I get a future warning about comparing to None. But I can live with that.

./SimulationFull.py:254: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
if frame == None:

I also get these warnings, but only when the code first starts up. So I think it's just because it hasn't found the image stream yet.

/home/bktaco/formulapi/ImageProcessor.py:926: RuntimeWarning: divide by zero encountered in divide
adjustment = 255.0 / maximum
/home/bktaco/formulapi/ImageProcessor.py:1003: RuntimeWarning: divide by zero encountered in divide
autoGainR = Settings.targetLevel / rAll.max()
/home/bktaco/formulapi/ImageProcessor.py:1004: RuntimeWarning: divide by zero encountered in divide
autoGainG = Settings.targetLevel / gAll.max()
/home/bktaco/formulapi/ImageProcessor.py:1005: RuntimeWarning: divide by zero encountered in divide
autoGainB = Settings.targetLevel / bAll.max()
/home/bktaco/formulapi/ImageProcessor.py:1007: RuntimeWarning: invalid value encountered in multiply
red = (red - dropR) * Settings.redGain * autoGainR
/home/bktaco/formulapi/ImageProcessor.py:1008: RuntimeWarning: invalid value encountered in multiply
green = (green - dropG) * Settings.greenGain * autoGainG
/home/bktaco/formulapi/ImageProcessor.py:1009: RuntimeWarning: invalid value encountered in multiply
blue = (blue - dropB) * Settings.blueGain * autoGainB

Everything runs as it was before. Now to fire up a new raspberry pi to test other things on and install the new packages without messing up the current testing environment.

Thanks for your help!

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Syntax highlight code surrounded by the <pre class="brush: lang">...</pre> tags, where lang is one of the following language brushes: bash, cpp, perl, python.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Comment Images
Files must be less than 10 MB.
Allowed file types: png gif jpg jpeg.
Comment Attachments
Files must be less than 10 MB.
Allowed file types: txt pdf nfo doc docx rtf jpg png gif bmp zip tar gz csv xls.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.