2012-08-26 284 views
0

如果我安裝最新的穩定1.2.7 django-haystacksudo pip install django-haystack,它工作正常。但是,卸載它,並安裝了最新開發版本2.0.0 BETA而不是作爲建議的主網頁後:ImportError:No module named haystack

pip install -e git+https://github.com/toastdriven/[email protected]#egg=django-haystack 

儘管下面的成功消息,現在看來似乎是安裝不正確:

Obtaining django-haystack from git+https://github.com/toastdriven/[email protected]#egg=django-haystack 
    Cloning https://github.com/toastdriven/django-haystack.git (to master) to ./src/django-haystack 
    Running setup.py egg_info for package django-haystack 

Installing collected packages: django-haystack 
    Running setup.py develop for django-haystack 
    Checking .pth file support in /usr/local/lib/python2.7/dist-packages/ 
    /usr/bin/python -E -c pass 
    TEST PASSED: /usr/local/lib/python2.7/dist-packages/ appears to support .pth files 

    Creating /usr/local/lib/python2.7/dist-packages/django-haystack.egg-link (link to .) 
    Adding django-haystack 2.0.0-beta to easy-install.pth file 

    Installed /home/kave/projects/cb/src/django-haystack 
Successfully installed django-haystack 
Cleaning up... 

因爲當我進入Django的shell環境,做一個

>>> from haystack import indexes 

Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
ImportError: No module named haystack 

我按照指示,並有 INSTALLED_APPS = (... 'haystack',)在那裏

我以前有這個問題,但永遠不能解決它。 sudo pip安裝默認工作正常,但只要我得到最新的Git版本,我的django似乎沒有看到它。

我可能會錯過什麼?

非常感謝您的諮詢,

UPDATE

道歉,但似乎在錯誤的Aptana Studio的3.0內只發生。在Django Shell中,我可以完成導入。我仍然眼花繚亂,因爲這應該是相同的。爲什麼Aptana在使用sudo pip install django-haystack進行安裝時可以看到這些庫,但如果使用最新的Git版本,則無法看到這些庫?請問那裏有什麼問題?

更新2

sys.path

['/home/kaveh/projects/cb', '/usr/local/lib/python2.7/dist-packages/requests-0.13.9-py2.7.egg', '/home/kaveh/projects/cb/src/django-haystack', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol'] 
+0

在你的shell中,當前目錄是什麼? sys.path的值? – nneonneo

+0

謝謝。我只是做了'print sys.path',我看到''/ home/kave/projects/cb/src/django-haystack','我看到那裏存在路徑。我的問題中也有完整的系統路徑。 – Houman

回答

1

我終於得到它的工作。我的問題是pip install -e git+https://github.com/toastdriven/[email protected]#egg=django-haystack顯然不工作。

我只是卸載它,並確保它被刪除。

然後,我只是下載的源爲zip文件,提取並

python setup.py build 
sudo python setup.py install 

這樣就會保證合作。希望這可以幫助某人。