Search code examples
bashpython-2.7modulepipsimplecv

Python No module named, even though the module does appear


Good day.

I've been using

pip install simplecv

to install the module simplecv.

I know the module was properly installed and when I'm printing list of the modules using

    #!/usr/bin/env python2.7
    import pip
    installed_packages = pip.get_installed_distributions()
    installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
         for i in installed_packages])
    print(installed_packages_list)

I can see it in the list : 'simplecv==1.3'

But for some reason I can't use it. I've tried to export the path using

1) export PYTHONPATH="/usr/local/lib/python2.7"
2) export PYTHONPATH="/usr/local/lib/python2.7/site-packages"
3) export PYTHONPATH="/usr/local/lib/python2.7/dist-packages"

But nothing works

Any ideas?


Solution

  • The package name isn't the same as the module name. The module is called SimpleCV, as shown in the documentation. So we have

    >>> import simplecv
    Traceback (most recent call last):
      File "<ipython-input-2-064db77601b3>", line 1, in <module>
        import simplecv
    ImportError: No module named simplecv
    

    but

    >>> import SimpleCV
    Traceback (most recent call last):
      File "<ipython-input-3-d3da1d75bea1>", line 1, in <module>
        import SimpleCV
      File "/usr/local/lib/python2.7/dist-packages/SimpleCV/__init__.py", line 3, in <module>
        from SimpleCV.base import *
      File "/usr/local/lib/python2.7/dist-packages/SimpleCV/base.py", line 59, in <module>
        raise ImportError("Cannot load OpenCV library which is required by SimpleCV")
    ImportError: Cannot load OpenCV library which is required by SimpleCV
    

    I didn't bother installing the dependencies, so this didn't work, but if I had, it would have. :-)