Simplecv: Python3

Created on 6 Jul 2016  ·  11Comments  ·  Source: sightmachine/SimpleCV

Seems SimpleCV is not running with Python3. Since Python2 is being phased out, I hope this gets fixed fairly soon.

This is what I get with sudo pip3 install SimpleCV:

  Running setup.py install for SimpleCV
      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/DrawingLayer.py", line 40
        def __init__(self, (width, height)):
                           ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/base.py", line 139
        print 'unit test'
                        ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Color.py", line 213
        print a
              ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Features/BOFFeatureExtractor.py", line 68
        print "Opening file: " + infile
                             ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Features/Blob.py", line 876
        print self.mHullMask
                 ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Features/BlobMaker.py", line 97
        except RuntimeError,e:
                           ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/EXIF.py", line 1182
        y = 0L
             ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Font.py", line 68
        print "Please pass a string"
                                   ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/MachineLearning/TreeClassifier.py", line 190
        print "Opening file: " + infile
                             ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/MachineLearning/SVMClassifier.py", line 181
        print "Opening file: " + infile
                             ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/MachineLearning/NaiveBayesClassifier.py", line 120
        print "Opening file: " + infile
                             ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/MachineLearning/KNNClassifier.py", line 153
        print "Opening file: " + infile
                             ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Stream.py", line 62
        except socket.error, e:
                           ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/ImageClass.py", line 132
        print "You need to install Beatutiul Soup to use this function"
                                                                      ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Camera.py", line 363
        print "coord: (" + str(d.mouseX) + "," + str(d.mouseY) + "), color: " + str(i.getPixel(d.mouseX,d.mouseY))
                       ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/tests/test_display.py", line 80
        print val
                ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/tests/YCrCbtests.py", line 6
        print "Converted to YCrCb\n"
                                   ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/tests/vcamera_tests.py", line 19
        print str(i) + ": " + str(props[i]) + "\n"
                ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/tests/test_cameras.py", line 17
        print str(i) + ": " + str(props[i]) + "\n"
                ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/tests/tests.py", line 74
        print val
                ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/tests/test_optional.py", line 91
        print foundtext
                      ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/tests/test_stereovision.py", line 54
        print val
                ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Shell/Shell.py", line 71
        print "args", arg
                   ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Shell/Example.py", line 28
        print "Available Examples:"
                                  ^
    SyntaxError: Missing parentheses in call to 'print'

      File "/usr/local/lib/python3.4/dist-packages/SimpleCV/Shell/Tutorial.py", line 35
        print lb
               ^
    SyntaxError: Missing parentheses in call to 'print'

Most helpful comment

Hi @mUtterberg ... my fork attempted to move SimpleCV from Python2 to Python3. I fixed most of the issues. The main blocker currently is the internal data handling. SimpleCV uses a 3 channel (RGB) iplimage internally as a default, but iplimage is deprecated. It is recommended to use numpy.ndarray instead, but I hadn't found the time to port any code. I am willing to help out if you (or anyone else) has questions.

All 11 comments

If the missing parens are the only thing needed to migrate then this will be an easy fix. I will try to consult an expert on migration to see what other concerns there might be.

To correct you on a few things: Python2, or more accurately, Python27 is not being phased out - there are some decent attempts from various sources to do so, but those who know what in the world are they doing, don't budge under the pressure. Python3X compared to Python27 is a tonne more confusing, weird, and frustrating, not something I'd recommend to programming newbies. Just go ahead and try Python27, and trust me when I say, that you'll love it (unless you got used to many Python3X-specific functions that is, and let me tell you, there aren't a lot of those)

Edit: This is a few years old statement, I'll keep it here, but it is not valid anymore.

Support for Python 2.7 is ending in 2020, so I do think it's a valid concern. I feel like importing futures is a simple way to refactor the print statement errors. Does anyone know what else would need to change in order to enable forward compatibility?

@mUtterberg There's also the OpenCV2 to OpenCV3 upgrade the SimpleCV framework has to undergo.

I'm new to Python and hoping to get started with some camera/vision coding on my Raspberry Pi. I've installed OpenCV 3.4.1 already (Eventually) but I think simplecv would be a better starting point.

But the simplecv website seems pretty out of date and as seen above, the install wont work properly with Python 3.

I've tried installing simplecv but when I try to run simplecv from the command line, I get all the same print errors as above. I have tried to fix these by adding the parentheses to the Python code but then I start getting various 'import' errors when I try to run simplecv.

I don't know how hard it would be to get simplecv updated to work on Python3, but I'd certainly appreciate trying it if/when it happens.

Below are the errors I'm getting now...

pi@raspberrypi:~ $ simplecv
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xa
Traceback (most recent call last):
File "/usr/local/bin/simplecv", line 7, in
from SimpleCV.Shell import main
File "/usr/local/lib/python3.5/dist-packages/SimpleCV/__init__.py", line 3, in
from SimpleCV.base import *
File "/usr/local/lib/python3.5/dist-packages/SimpleCV/base.py", line 26, in
import scipy.ndimage as ndimage
File "/usr/local/lib/python3.5/dist-packages/scipy/ndimage/__init__.py", line 161, in
from .filters import *
File "/usr/local/lib/python3.5/dist-packages/scipy/ndimage/filters.py", line 37, in
from . import _nd_image
ImportError: numpy.core.multiarray failed to import

@chrisgavinlondon, Sight Machine does seem to have abandoned this library, but there are numerous forks of it. I ended up forking it and have changed it to the point that I can install and run it on my Raspberry Pi, which defaults to Python 2.7 . The bugs from the 2.7 perspective were SUPER easy fixes once I was running my fork's version. I'm working on getting it up to a modern version of Python, but I'm sure others have been working on their own forks much longer than I have! At this point, we may be better off picking someone's solid fork and taking our SimpleCV party there.
But who knows?? Maybe @andrewbaldock @bremac @demaagdk @doclrogers @idfarmer @mechiris @oostendo @struckmannk or @xamox will see one of these threads and decide to loop people in for help! Maintaining a library, especially one this substantial, is a lot of work.

Hi @mUtterberg ... my fork attempted to move SimpleCV from Python2 to Python3. I fixed most of the issues. The main blocker currently is the internal data handling. SimpleCV uses a 3 channel (RGB) iplimage internally as a default, but iplimage is deprecated. It is recommended to use numpy.ndarray instead, but I hadn't found the time to port any code. I am willing to help out if you (or anyone else) has questions.

Hi @mUtterberg ... my fork attempted to move SimpleCV from Python2 to Python3. I fixed most of the issues. The main blocker currently is the internal data handling. SimpleCV uses a 3 channel (RGB) iplimage internally as a default, but iplimage is deprecated. It is recommended to use numpy.ndarray instead, but I hadn't found the time to port any code. I am willing to help out if you (or anyone else) has questions.

Hi @mUtterberg I just wanna use SimpleCV to find a circle, do you thing with you fork I can do it? Or is it still not ready? Thanks

+1

Python 2 is officially sunset. Is there any plans to make simplecv python 3 compatible? It's a cool and simple to understand package. Thanks.

@jairoareyes I ended up using OpenCV itself, as recent releases of the python api are much more intuitive and more or less negate the need for a third-party api.

Was this page helpful?
0 / 5 - 0 ratings