2017-09-16 109 views
0

我用下面的命令蟒蛇simhash進口問題[github.com/seomoz/simhash-py]

pip install git+https://github.com/seomoz/simhash-py.git 

,並檢查是否已成功安裝在它下面安裝simhash是pip freeze的O/P

pip freeze | grep simhash 
You are using pip version 8.1.1, however version 9.0.1 is available. 
You should consider upgrading via the 'pip install --upgrade pip' command. 
simhash-py==0.4.0 

當運行下面的測試的情況下,即,

import unittest 
import simhash 

class TestNumDifferingBits(unittest.TestCase): 
    '''Tests about num_differing_bits''' 

    def test_basic(self): 
     a = 0xDEADBEEF 
     b = 0xDEADBEAD 
     self.assertEqual(2, simhash.num_differing_bits(a, b)) 

if __name__ == '__main__': 
    unittest.main() 

這是我從複製,我得到了下面的錯誤

ImportError: Failed to import test module: simhashGitHubTest 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/unittest/loader.py", line 254, in _find_tests 
    module = self._get_module_from_name(name) 
    File "/usr/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name 
    __import__(name) 
    File "/home/pallav/PycharmProjects/pfda/src/simhashTest/simhashGitHubTest.py", line 4, in <module> 
    import simhash 
ImportError: No module named simhash 

然後,我更換了包的名稱以simhash-PY(如PIP)由於我得到了以下錯誤:

import simhash-py as simhash 
       ^
    SyntaxError: invalid syntax 

請幫我在運行測試用例。

pip -V 
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7) 

命令運行測試案例(從PyCharm複製)

python -m unittest discover -s /home/pallav/PycharmProjects/pfda/src/simhashTest -p simhashGitHubTest.py -t /home/pallav/PycharmProjects/pfda/src/simhashTest in /home/pallav/PycharmProjects/pfda/src/simhashTest 
+0

可以粘貼PIP的'結果-V'在終端? – PRMoureu

+0

@PRMoureu完成,請檢查 –

+0

好的,以及如何執行測試文件? – PRMoureu

回答

0

我經由另一方法安裝它。

git clone https://github.com/seomoz/simhash-py.git 
cd simhash-py 
git submodule update --init --recursive 

然後命名參數「名」的值從simhash-py改爲simhash這是傳遞給setup方法~/setup.py文件,然後

sudo python setup.py install