Reputation: 65
I have the newest Anaconda 2.3 on a non-network-Linux-machine. Everything works fine besides
import sklearn
I then get back
----> 1 import sklearn
sklearn.py in <module>()
ValueError: Attempted relative import in non-package
I have to go into the /pkgs folder in anaconda and into scikit-learn to import from there. This works and whats even weirder, when I type
import
and the tabulator to show possible packages, sklearn is shown.
Upvotes: 2
Views: 2365
Reputation: 935
Might be that you're using another Python installation on your computer.
For instance, I have Python in my Anaconda environement and the other one by default. If execute: ~/anaconda/bin/python
I can import sklearn without problems.
On the contrary if I execute /usr/bin/python
and then try to export it I get the error message since I installed sklearn from Anaconda.
Check your PATH variable with typing $PATH
on your terminal and check the order, if Anaconda is not the first one (or it's not there) type: export PATH="/path/to/anaconda/bin:$PATH"
I hope this works.
Upvotes: 2