2013-03-25 70 views
4

我在虛擬環境中安裝項目。我得到的錯誤該模塊的python中的zope.interface.registry導入錯誤

from zope.interface.registry import Components 
Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
ImportError: No module named registry 

版本爲4.0.5

>>> import pkg_resources 
>>> pkg_resources.get_distribution("zope.interface").version 
'4.0.5' 

我想在我的機器上是相同的(不是虛擬ENV),

>>> import pkg_resources 
>>> pkg_resources.get_distribution("zope.interface").version 
'4.0.1' 
>>> from zope.interface.registry import Components 

這裏from zope.interface.registry import Components沒」不要給任何錯誤。根據this

QUOTE: 3.8.0 (2011-09-22) 
New module zope.interface.registry. This is code moved from 
zope.component.registry which implements a basic nonperistent component registry 
as zope.interface.registry.Components. 

,它不應該給任何錯誤。任何建議我在這裏失蹤或如何解決這個錯誤?

+0

我無法複製這是一個新鮮的virtualenv。你可以在'ls lib/python */site-packages/zope/interface'中看到'registry.py'文件嗎? – 2013-03-25 08:41:12

+0

在虛擬環境中安裝項目之前,我已經在系統上安裝了zope。我檢查了我的虛擬和非虛擬環境中導入模塊(zope.interface)的路徑。虛擬''/usr/lib/python2.7/dist-packages/zope/interface/ __ init __。pyc''和非虛擬的是'/usr/local/lib/python2.7/dist-packages/zope.interface- 4.0.1-py2.7-Linux的x86_64.egg/zope的/接口/ __的init __。pyc'。只有在非虛擬位置,我可以找到'registry.py' – Netro 2013-03-25 10:00:37

+0

虛擬環境中的'ls'命令告訴你什麼? 'import zope.interface; print(zope.interface .__ file __)'是什麼意思? – 2013-03-25 10:02:17

回答

4

我有類似的錯誤 - 我嘗試創建新的虛擬env沒有站點包。它創造一切美好。但是我的Ubuntu已經安裝了zope.interface供自己使用,所以它不想將它安裝在我的venv上。

該碰撞導致我VENV拋出錯誤在簡單的測試應用下的mod_wsgi:

 from zope.interface.registry import Components 
ImportError: No module named registry 

所以我想從基地蟒蛇刪除zope.interface。但unistall命令沒有刪除它(我發現在谷歌,這是已知的問題)。

比我找到解決辦法:我剛換到我的VENV,並從那裏得到命令「升級」 zope.interface

(env)[email protected]:~/env$ sudo pip install --upgrade zope.interface 

這是我的問題zope.interface dissmiss後。

你的問題是類似的,所以我的解決方案可以幫助。無論如何,這個答案對Ubuntu桌面用戶非常有用。