简体   繁体   中英

ImportError: No module named zope.interface

I am trying to run server for iphone using http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-server

My machine is mac 10.6.8 Python version : 2.7.3 I dont have any knowledge regarding python. i have installed Twisted-12.1.0 additionally but still i am getting this error.

Traceback (most recent call last): File "chatserver.py", line 1, in from twisted.internet.protocol import Protocol, Factory File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/protocol.py", line 15, in from zope.interface import implements ImportError: No module named zope.interface

later i have downloaded zope.app.wsgi-3.15.0 4 but i dont know how to use it.

The problem is that an __init__.py file is not present under zope directory so this directory is not scanned for imports.

Creating a blank __init__.py file under zope directory will do the trick.

I solved this error in UNIX by browsing to the zope directory by executing:

$touch __init__.py

I can confirm that this works also with virtualenv pip installation of zope interface

Here's a solution

It says that installing a zope module through pip breaks your zope installation because pip installs it in another directory other than the original zope module directory.

From the link

After install a zope module using pip, for example z3c.password your zope installation gets broken.

This is because pip have installed the module in /usr/local/lib/python2.6/dist-packages/zope and the original module zope.interface is in /usr/share/pyshared/zope/interface/ and has minor relevance when importing.

What worked for me is (also given in the link):

cd /usr/local/lib/python2.7/dist-packages/zope 
sudo ln -s /usr/share/pyshared/zope/interface/

Off the top of my head you can use easy_install for this.

You will need the python-setuptools then you should be able to use

easy_install zope.interface

If I remember correctly however twisted should be installed as part of OS X python install. Do a quick Google for installing zope.interface for Mac OS X. As twisted is such a widely used library there is plenty of information out there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM