我尝试运行一些Python代码,但遇到此错误:
错误:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-27-272a94e26f8f> in <module>
1 # Compute the WMD of the two sentences
----> 2 distance = model.wmdistance(question1, question2)
3 print('distance = %.4f' % distance)
~/env/lib64/python3.6/site-packages/gensim/models/keyedvectors.py in wmdistance(self, document1, document2)
714 # If pyemd C extension is available, import it.
715 # If pyemd is attempted to be used, but isn't installed, ImportError will be raised in wmdistance
--> 716 from pyemd import emd
717
718 # Remove out-of-vocabulary words.
ModuleNotFoundError: No module named 'pyemd'
我尝试导入pyemd
>>> import pyemd
ModuleNotFoundError: No module named 'pyemd'
我也尝试在这里安装它:
-bash-4.2$ pip install --user pyemd
Collecting pyemd
Requirement already satisfied: numpy<2.0.0,>=1.9.0 in /usr/local/lib/python3.7/site-packages (from pyemd) (1.16.2)
Installing collected packages: pyemd
Successfully installed pyemd-0.5.1
-bash-4.2$ python
Python 2.7.5 (default, Jun 11 2019, 12:19:05)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyemd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyemd
我已经按照here上的说明进行操作,但是我没有root权限来运行以下conda create -n test-pyemd && source activate test-pyemd