I've had this same problem. To expound a bit, PyCharm uses iPython if you have it installed, and iPython uses zope.interface also. I'm on a Mac developing a Pyramid project (which uses zope.inerface) and see this behavior:
Python in system Terminal
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import zope.interface
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named interface
>>>
iPython in system Terminal
$ ipython
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
Type "copyright", "credits" or "license" for more information.
IPython 3.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import zope.interface
In [2]:
Note that it imports without an error - and it's using the same python interpreter as the 1st example!
Python Console in PyCharm
According to PyCharm docs, this uses iPython, and we see this is try from the startup output:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 -u /Applications/PyCharm.app/Contents/helpers/pydev/pydevconsole.py 63304 63305
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
Type "copyright", "credits" or "license" for more information.
IPython 3.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
PyDev console: using IPython 3.1.0
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['/Users/someone/PycharmProjects/SMS_PUB_API'])
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
In[2]: import zope.interface
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/IPython/core/interactiveshell.py", line 3035, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-bc61dfc4e3ea>", line 1, in <module>
import zope.interface
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named interface
In[3]:
Note that if I use PyCharm's Terminal feature to then use the system Python and iPython consoles, i get the same results as the 1st 2 examples above.
Running Pyramid from PyCharm
The odd part is, if I run my Pyramid project from within PyCharm (Which uses zope.interfaces) using the same project interpreter as the above examples , it starts up just fine
It's tempting to think it's an issue with the zope.interface module being named with a dot in it - that's normally reserved python terminology to express a path. However, other zope.* modules import just fine. I went into PyCharm's Project Interpreter settings and noticed I was using zope.interface 4.1.1 and that 4.1.2 is out. After updating (in pycharm), it works fine - i can now import zope.interfaces.
Note, this also happened in the normal Mac Terminal. Before writing this post, i could not import it with iPython. After upgrading iPython, it worked in the terminal (my 2nd example above).
Hope this helps!