scikit-learn-contrib / py-earth

A Python implementation of Jerome Friedman's Multivariate Adaptive Regression Splines
http://contrib.scikit-learn.org/py-earth/
BSD 3-Clause "New" or "Revised" License
455 stars 122 forks source link

Import on windows, can't find pyearth._forward module #89

Closed Ljens closed 8 years ago

Ljens commented 8 years ago

Hi

I have downloaded and installed pyearth from zip file on my windows machine. Installation was via pip and seemed to work fine, but when I try to import pyearth, I get the following error:

import pyearth Traceback (most recent call last): File "", line 1, in import pyearth File "c:\users\lindenj\downloads\py-earth-master\py-earth-master\pyearthinit.py", line 8, in from .earth import Earth File "c:\users\lindenj\downloads\py-earth-master\py-earth-master\pyearth\earth.py", line 1, in from ._forward import ForwardPasser ImportError: No module named 'pyearth._forward'

I am not sure why this is happening, since the pyearth._forward.pyd file is in the \site-packages\pyearth directory. On the same day I downloaded and installed pyearth on my mac using the git clone command line tool, and it works fine (ie. can import).

I am pretty new to using github, not sure if these is something wrong with the download files, or I have stuffed something up. Please help!

jcrudy commented 8 years ago

@ljensenpage It looks like you're importing the copy in your downloads directory rather than the one in sit-packages. Probably the copy in your downloads directory is in the python path somehow. I would try just deleting the copy in your downloads directory and see if it works then.

Ljens commented 8 years ago

Thanks for the reply @jcrudy!

I have done as you say, and now get an error concerning cython:

import pyearth Traceback (most recent call last): File "", line 1, in import pyearth File "C:\Users\lindenj\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyearthinit.py", line 8, in from .earth import Earth File "C:\Users\lindenj\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyearth\earth.py", line 1, in from ._forward import ForwardPasser TypeError: Shared Cython type cython_function_or_method is not a type object

Thanks very much for your help.

Regards L

jcrudy commented 8 years ago

Just to narrow it down, maybe try this:

  1. Uninstall py-earth by deleting anything it put in site-packages
  2. Unpack the py-earth zip file somewhere
  3. From within py-earth-master run:

    python setup.py install build_ext --inplace

  4. Then run:

    nosetests -s -v .

If nose isn't installed, you'll need to install it. The above steps should build py-earth in place and then run the unit tests. If the tests pass, you know at least that you are able to compile C extensions and run py-earth on your system. In that case the problem probably has something to do with paths or different versions of Python. I am kind of guessing, here, though. This might be a question for stack overflow.

jcrudy commented 8 years ago

Closing this because I think it isn't a bug in py-earth. Please reopen if I'm wrong.

feng-1985 commented 6 years ago

The same error to me. Solution: After install it, just delete the git download packages[py-earth].