scikit-learn / scikit-learn

scikit-learn: machine learning in Python
https://scikit-learn.org
BSD 3-Clause "New" or "Revised" License
59.95k stars 25.38k forks source link

build issues #433

Closed dawenl closed 12 years ago

dawenl commented 12 years ago

Hi all,

I tried to install scikit-learn on my Mac with Lion 10.7.2 (Python 2.7, numpy 1.6.1). At first I tried easy_install and got scikit-0.9 but cannot import due to some 'Don't forget to 'make' first' error and then I searched online, finding that this issue should be fixed in the newer version in github. So I checked out the code and build from source using the following two commands:

python setup.py build sudo python setup.py install

Now I've got scikit-0.10 in /Library/Python/2.7/site-packages. However, when I tried to run the tests, similar error shows up:

Traceback (most recent call last): File "", line 1, in File "sklearn/init.py", line 30, in """ % e) ImportError: No module named _check_build


It seems that the scikit-learn has not been built correctly.

If you have installed the scikit-learn from source, please do not forget to build the package before using it: run python setup.py install or make in the source directory.

If you have used an installer, please check that it is suited for your Python version, your operating system and your platform.

I didn't see errors in my build and build is finished with 'running scons'. I don't know where I am doing wrong. If you need to know more, please let me know. Any help would be very appreciated. Thanks!

GaelVaroquaux commented 12 years ago

Do you have a _check_build library (I don't know if it's a '.so' or something else under OSX) in the corresponding library? Optionally, you can try with the latest development version of the scikit: I have made a change that will not fix your problem, but that will give a more informative error that you can copy-paste here.

I suspect that you have a build problem.

dawenl commented 12 years ago

I do have a _check_build.so under /Library/Python/2.7/site-packages/scikit_learn-0.10-blabla/sklearn/check_build folder.

I will check out the newer code now and post the results so asap.

dawenl commented 12 years ago

BTW, I found that I could import scikits module successfully, I am not sure what that means though.

dawenl commented 12 years ago

Here is the new output from test:

Traceback (most recent call last): File "", line 1, in File "sklearn/init.py", line 16, in from . import check_build File "sklearn/check_build/init.py", line 29, in """ % (e, local_dir, ''.join(dir_content).strip())) ImportError: No module named _check_build


Contents of sklearn/check_build: init.py init.pyc _check_build.c _check_build.pyx setup.py setup.pyc


It seems that the scikit-learn has not been built correctly.

If you have installed the scikit-learn from source, please do not forget to build the package before using it: run python setup.py install or make in the source directory.

If you have used an installer, please check that it is suited for your Python version, your operating system and your platform.

GaelVaroquaux commented 12 years ago

On Tue, Nov 08, 2011 at 01:46:10PM -0800, Dawen Liang wrote:

ImportError: No module named _check_build


Contents of sklearn/check_build: init.py init.pyc _check_build.c _check_build.pyx setup.py setup.pyc


It seems that the scikit-learn has not been built correctly.

OK, it's probably because you are trying to import the scikit from the build directory. Just 'cd' elsewhere, and try again.

G

dawenl commented 12 years ago

OK. Then the error becomes: (I saw this error previously while using easy_install)

Traceback (most recent call last): File "", line 1, in File "/Library/Python/2.7/site-packages/scikit_learn-0.10_git-py2.7-macosx-10.7-intel.egg/sklearn/init.py", line 17, in from .base import clone File "/Library/Python/2.7/site-packages/scikit_learn-0.10_git-py2.7-macosx-10.7-intel.egg/sklearn/base.py", line 11, in from .metrics import r2_score File "/Library/Python/2.7/site-packages/scikit_learn-0.10_git-py2.7-macosx-10.7-intel.egg/sklearn/metrics/init.py", line 12, in from . import cluster File "/Library/Python/2.7/site-packages/scikit_learn-0.10_git-py2.7-macosx-10.7-intel.egg/sklearn/metrics/cluster/init.py", line 11, in from .unsupervised import silhouette_score, silhouette_samples File "/Library/Python/2.7/site-packages/scikit_learn-0.10_git-py2.7-macosx-10.7-intel.egg/sklearn/metrics/cluster/unsupervised.py", line 10, in from ..pairwise import pairwise_distances File "/Library/Python/2.7/site-packages/scikit_learn-0.10_git-py2.7-macosx-10.7-intel.egg/sklearn/metrics/pairwise.py", line 38, in from scipy.spatial import distance File "/Library/Python/2.7/site-packages/scipy-0.11.0.dev_04b8d87_20111104-py2.7-macosx-10.7-x86_64.egg/scipy/spatial/init.py", line 26, in from ckdtree import * File "numpy.pxd", line 174, in init scipy.spatial.ckdtree (scipy/spatial/ckdtree.c:8262) ValueError: numpy.ndarray has the wrong size, try recompiling

GaelVaroquaux commented 12 years ago

On Tue, Nov 08, 2011 at 01:51:53PM -0800, Dawen Liang wrote:

File "/Library/Python/2.7/site-packages/scipy-0.11.0.dev_04b8d87_20111104-py2.7-macosx-10.7-x86_64.egg/scipy/spatial/init.py", line 26, in from ckdtree import * File "numpy.pxd", line 174, in init scipy.spatial.ckdtree (scipy/spatial/ckdtree.c:8262) ValueError: numpy.ndarray has the wrong size, try recompiling

My guess is that this is a problem with scipy, and not with the scikit: "from scipy import spatial" will probably not work.

It seems to me that scipy has been build with a different version of numpy. You need to rebuild it.

dawenl commented 12 years ago

You are right that I cannot import spatial from scipy.

Actually I got some problems building scipy, so I just used trick to directly put the compiled package in my /Library/Python/2.7/site-packages. Looks like this won't work... Thanks for your help. I will turn to scipy for help now.

ogrisel commented 12 years ago

You should use scipy superpack under OSX: stronginference.com/scipy-superpack/

dawenl commented 12 years ago

Yes, that's what I did just now. And now I could import scikits finally and run a logistic regression successfully. Though I got segmentation fault while running the tests. Maybe I will start a new thread for this.

ogrisel commented 12 years ago

Yes. Especially if you can narrow down which compiled extension is causing the segfault.

vene commented 12 years ago

I have the same segfault I think. I think it's in arpack because all examples in the manifold module crash as well. I will submit a full report soon.

dhruvbird commented 9 years ago

I get the same error if I start python from the build directory, but not otherwise.

amueller commented 9 years ago

@dhruvbird that is likely due to the fact that you have another version of sklearn installed, that gets called if you don't run from the build directory.