这个python代码
import numpy as np
from scipy.spatial.distance import euclidean
a = np.array([5,3,4,-1,0]);
b = np.array([2,4,0,-5,-2]);
dist = euclidean(a,b);
print ("Distancia = "+ str(dist) );
simil = 1/(1+dist);
print ('Similitud = '+ str(simil) );
在spyder运行没有问题,但在pycharm我收到此错误消息
/home/user/anaconda3/envs/prueba2/bin/python /home/user/PycharmProjects/prueba2/prueba2.py
Traceback (most recent call last):
File "/home/user/PycharmProjects/prueba2/prueba2.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
这是项目翻译
pip3 install numpy
pip install numpy
在终端中使用上面的命令并为python 3.6安装numpy然后再试一次。