Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

python - ImportError: cannot import name inplace_column_scale

Using Python 2.7 with scikit-learn 0.14 package. It runs well on some examples from the user guild expect the Linear Models.

Traceback (most recent call last):
File "E:Pplot_ols.py", line 28, in <module>
from sklearn import datasets, linear_model
File "C:Python27libsite-packagessklearnlinear_model\__init__.py", line 12, in    <module>
from .base import LinearRegression
File "C:Python27libsite-packagessklearnlinear_modelase.py", line 29, in <module>
from ..utils.sparsefuncs import mean_variance_axis0, inplace_column_scale
ImportError: cannot import name inplace_column_scale

Thank you~

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was able to fix this by going to my python folder and deleting the file:

python27Libsite-packagessklearnutilssparsefuncs.pyd

My guess is that the problem was:

  1. An older version of scikit-learn implemented sparsefuncs as a windows DLL
  2. The current version implements it as a python file
  3. If you install a new version on top of an old version it does not delete the old DLL
  4. When you try to import, Python uses the pyd in preference to the py implementation
  5. But the old implementation did not include this function

This suggests that there might be bigger problems caused by installing a new version and it might be wise to delete the whole sklearn directory before reinstalling the new version.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...