相关文章推荐
直爽的牛肉面  ·  python/openpyxl/DataVa ...·  1 周前    · 
勤奋的鸭蛋  ·  python - Set up of ...·  2 天前    · 
大力的长颈鹿  ·  python - Conda env ...·  2 天前    · 
憨厚的毛衣  ·  @ComponentScan( ...·  1 年前    · 
温柔的小蝌蚪  ·  android - ...·  2 年前    · 
坐怀不乱的山羊  ·  jquery;延时器 ...·  2 年前    · 
销魂的香菜  ·  c# 实现网页(Web ...·  2 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I installed scikit-learn successfully on Ubuntu following these instructions .

However, I get this error when I run a program that uses it:

Traceback (most recent call last):
  File "begueradj.py", line 10, in <module>
    from sklearn.preprocessing import normalize
ImportError: No module named sklearn.preprocessing

How do I fix this?

The instructions given in that tutorial you linked to are obsolete for Ubuntu 14.04.

The Ubuntu 14.04 package is named python-sklearn (formerly python-scikits-learn):

sudo apt-get install python-sklearn  

The python-sklearn package is in the default repositories in Ubuntu 14.04 as well as in other currently supported Ubuntu releases.

normalize is a method of Preprocessing. Therefore you need to import preprocessing.

In your code you can then call the method preprocessing.normalize().

from sklearn import preprocessing
preprocessing.normailze(x,y,z)

If you are looking to make the code short hand then you could use the import x from y as z syntax

from sklearn import preprocessing as prep
prep.normalize(x,y,z) 
                No, this is not the issue here: from sklearn.preprocessing import normalize is a perfectly valid import.
– cel
                Mar 21, 2015 at 12:58
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.