Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...