[Tutor] ImportError: cannot import name

Peter Otten __peter__ at web.de
Wed Aug 31 04:46:12 EDT 2016


fa306795 at skynet.be wrote:

> Hello,
> I use python 3.5.1 and try to import sompy and get the following error:
> 
> File
> "C:\Anaconda3\lib\site-packages\sompy-1.0-py3.5.egg\sompy\__init__.py",
> line 30, in <module>     from sompy import SOMFactory
> 
> ImportError: cannot import name 'SOMFactory'
> 
> What could cause such an error? Thanks in advance for any suggestions.

The library in question seems to be

https://github.com/sevamoo/SOMPY

Given a package structure

sompy/
   __init__.py
   sompy.py
   ...

the line

from sompy import SOMFactory

is a relative import in Python 2 and fetches the name SOMFactory from the 
sompy.sompy submodule, but an absolute import in Python 3 which tries to 
access the (inexistent) sompy.SOMFactory from the file sompy/__init__.py.

Thus it looks like SOMPY requires Python 2.




More information about the Tutor mailing list