2012-02-09 83 views
0

我正在使用python-sshtail模塊ssh到Linux服務器並尾部文件。Python SSHTail - 無法導入SSHTailer

我只是想出來的示例代碼(位於:https://github.com/praekelt/python-sshtail),我立即發現了以下錯誤:

ImportError: cannot import name SSHTailer 

任何幫助,將不勝感激。

感謝

編輯:

我的安裝是這樣的:

sshtail-0.0.2-py2.7.egg 
Processing dependencies for python-sshtail 
Searching for paramiko 
Reading http://pypi.python.org/simple/paramiko/ 
Reading http://www.lag.net/~robey/paramiko/ 
Reading http://www.lag.net/paramiko/ 
Best match: paramiko 1.7.7.1 
Downloading http://www.lag.net/paramiko/download/paramiko-1.7.7.1.zip 
Processing paramiko-1.7.7.1.zip 
Running paramiko-1.7.7.1\setup.py -q bdist_egg --dist-dir c:\docume~1\pgajaria\locals~1\temp\easy_install-hp2mfh\paramiko-1.7.7.1\egg-dist-tmp-0_v2ai 
warning: no files found matching 'user_rsa_key' under directory 'demos' 
warning: no files found matching 'user_rsa_key.pub' under directory 'demos' 
zip_safe flag not set; analyzing archive contents... 
Adding paramiko 1.7.7.1 to easy-install.pth file 
Installed c:\<blanked out>\python\lib\site-packages\paramiko-1.7.7.1-py2.7.egg 

爲Python-sshtail成品加工的依賴

+0

。例如,如果我只有「導入sshtaiL」,我不會收到任何錯誤。 – Parth 2012-02-09 15:40:02

+0

您正在使用'從sshtail import SSHTailer'導入? – 2012-02-09 16:03:49

+0

對不起。澄清,當我「從sshtail導入SSHTailer」,但我沒有導入sshtail時,我得到一個錯誤。我也試着將在線和示例代碼中的類複製到同一個文件中,但它確實有效,但我更希望導入工作正常。 – Parth 2012-02-09 18:36:30

回答

1

我通過電子郵件誰寫的庫中的開發人員,我有以下響應這解決了這個問題:我已經安裝了它

Very strange... It worked fine in my testing. You didn't perhaps call your own script "sshtail.py", did you? In that case, there will be a name conflict with the installed "sshtail" library, resulting in Python trying to import your script instead of the installed library.

1

看起來工作得很好,我(的Mac OSX獅子, Python 2.7.2)。你確定你正確安裝了python-sshtail嗎?

$ mkvirtualenv test-sshtail # optional, of course 

... making a virtualenv 

(test-sshtail)$ pip install python-sshtail 

... installing 

(test-sshtail)$ python 
Python 2.7.2 (default, Feb 4 2012, 02:01:30) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from sshtail import SSHTailer 
>>> print "No problem!" 

請在這裏沒有幫助的情況下發布更多詳情!

+0

我編輯了我的原始問題以顯示安裝過程。它似乎已經正確安裝。 – Parth 2012-02-09 15:39:41

+0

難道是你試圖在不同的Python環境中導入它?例如,如果您使用[Textmate](http://macromates.com/),您會發現在編輯器中用於運行腳本的Python版本可能與您安裝'sshtail'的版本不同。嘗試檢查'哪個python'和'哪個easy_install'或'哪個pip'的輸出。 這是您唯一遇到安裝/導入問題的軟件包嗎? – modocache 2012-02-09 15:52:24

+0

這是我導入麻煩的唯一軟件包。我100%確定Python安裝是我用來運行它的一個。特別是因爲我可以輸入「import sshtail」而沒有錯誤 – Parth 2012-02-09 18:37:18