设置: 操作系统:Win8.1 64位, IDE:JetBrains PyCharm, Python:3.5, 使用pip
安装SciPy和NumPy:cp35 64位whl文件代码:
import numpy as np
from scipy.interpolate import UnivariateSpline
from matplotlib import pyplot as plt
N = 1000
n = N/10
s = np.random.normal(size=N) # generate your data sample with N elements
p, x = np.histogram(s, bins=n) # bin it into n = N/10 bins
x = x[:-1] + (x[1] - x[0])/2 # convert bin edges to centers
f = UnivariateSpline(x, p, s=n)
plt.plot(x, f(x))
plt.show()
错误报告:
C:\Users\gakadam\AppData\Local\Programs\Python\Python35\python.exe C:/Users/gakadam/PycharmProjects/pdf_curve/main.py
Traceback (most recent call last):
File "C:/Users/gakadam/PycharmProjects/pdf_curve/main.py", line 2, in <module>
from scipy.interpolate import UnivariateSpline
File "C:\Users\gakadam\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\interpolate\__init__.py", line 145, in <module>
from .interpolate import *
File "C:\Users\gakadam\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\interpolate\interpolate.py", line 16, in <module>
import scipy.special as spec
File "C:\Users\gakadam\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\special\__init__.py", line 601, in <module>
from ._ufuncs import *
File "scipy\special\_ufuncs.pyx", line 1, in init scipy.special._ufuncs (scipy\special\_ufuncs.c:26071)
ImportError: DLL load failed: The specified module could not be found.
Process finished with exit code 1
我可以将错误跟到_unfuncs.pyx文件,但我不知道如何纠正它。感谢帮助。谢谢。