Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Installation of pyearth with python 3.8.10 #221

Closed
pgr123 opened this issue May 7, 2022 · 57 comments
Closed

Installation of pyearth with python 3.8.10 #221

pgr123 opened this issue May 7, 2022 · 57 comments

Comments

@pgr123
Copy link

pgr123 commented May 7, 2022

Good evening
I tried to install pyearth with pip3 install sklearn-contrib-py-earth but I got errors.
I have installed sklearn with pip3 install -U scikit-learn without problem.
What can I do ? How can I install pyearth on python 3.8 ?
Thank you to help me.
Excuse my bad english (I am french).
P. Grandeau

@kevin-dietz
Copy link

@pgr123 Have you tried building it directly from source? I always have good luck with that. Assuming you are using anaconda in the default location, it would be:

git clone -b issue191 https://github.com/jcrudy/py-earth.git
cd py-earth && ${HOME}/anaconda3/bin/python setup.py -q install --cythonize
rm -Rf ${HOME}/anaconda3/bin/pyearth && mv pyearth ${HOME}/anaconda3/bin/

@bmreiniger
Copy link

This project is largely abandoned, and the pip release is out of date. There is a branch here that seems to work for most folks:
#210 (comment)

@jhogg11
Copy link

jhogg11 commented Nov 8, 2022

This project is largely abandoned, and the pip release is out of date. There is a branch here that seems to work for most folks: #210 (comment)

Are there any reasons for it being abandoned other than time cost to update the package?

@kevin-dietz
Copy link

@jhogg11 The main author has largely abandoned the project. However, there is nothing to stop someone from forking the repo and taking up the reins

@pgr123
Copy link
Author

pgr123 commented Nov 8, 2022

Thank you for your responses.
I know the "pip install git+https://github.com/scikit-learn-contrib/[email protected]". It worked with Python 3.8 but it does not work with Python 3.10 (and then with the new Ubuntu 22.04). I don't know why !

@kevin-dietz
Copy link

@pgr123 Haven't tried it on 3.10 but I can confirm it does work on 3.9. If you want to try it on 3.10, the following code may work for you:

git clone https://github.com/jcrudy/py-earth.git
cd py-earth  
python setup.py build_ext --inplace --cythonize
mv pyearth path/to/site-packages/python3.9/site-packages

@jhogg11
Copy link

jhogg11 commented Nov 8, 2022

@pgr123 Haven't tried it on 3.10 but I can confirm it does work on 3.9. If you want to try it on 3.10, the following code may work for you:

git clone https://github.com/jcrudy/py-earth.git
cd py-earth  
python setup.py build_ext --inplace --cythonize
mv pyearth path/to/site-packages/python3.9/site-packages

I'm also using 3.9 and this works for me. Thank you!

@pgr123
Copy link
Author

pgr123 commented Nov 9, 2022

Thank you but that does not work.
I got many errors like :
error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?

and at the end I got :
error: Command "x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/include/python3.10 -c pyearth/_util.c -o build/temp.linux-x86_64-3.10/pyearth/_util.o" failed with exit status 1

Do you think there is a solution ?
Have a good day.

@kevin-dietz
Copy link

@pgr123 the project has been abandoned so if you are dead set on using py-earth then my suggestion would be to use python 3.8 or 3.9

@pgr123
Copy link
Author

pgr123 commented Nov 9, 2022

It's a pity !
So, there is no mean to uses MARS (earth) with Python ?
And else, how can I downgrade to Python 3.9 ?
Thank you.

@pgr123
Copy link
Author

pgr123 commented Nov 10, 2022

The problem seems to be with Python 3.10.
I installed Python 3.9 but when I try
python3.9 -m pip install git+https://github.com/scikit-learn-contrib/[email protected]"
I get an error : No module named distutils.cmd
I don't know what to do ! That new version of Ubuntu with python 3.10 (bugged) is very difficult and for me, it seems unusable and take me a lot of time.
So I think there is for me only one solution : go back to Ubuntu 20.04 which works perfectly !!!!
Thank you but that new version is not usable, I'll wait the version 22.04.5 or 22.04.6 !!!!!!!

@pgr123
Copy link
Author

pgr123 commented Nov 10, 2022

Even Spyder does not work with Ubuntu 22.04.1 and Python 3.10 !

@vea-therese
Copy link

@pgr123 Haven't tried it on 3.10 but I can confirm it does work on 3.9. If you want to try it on 3.10, the following code may work for you:

git clone https://github.com/jcrudy/py-earth.git
cd py-earth  
python setup.py build_ext --inplace --cythonize
mv pyearth path/to/site-packages/python3.9/site-packages

does this work when I'm installing pyEarth on a virtual environment? (i.e a Django environment)

@pgr123
Copy link
Author

pgr123 commented Nov 12, 2022

How can I install py-earth on a virtual environment ? I never used virtual environment and I don't know what Django is.
Thank you.
Have a good day.

@pgr123
Copy link
Author

pgr123 commented Nov 12, 2022

The update to Spyder 5.4.0 works with Ubuntu 22.04.1 and Python 3.10.6 but I have actually no solution for py-earth.
Someone know how to do a earth model ( MARS : Multivariate Adaptive Regression Splines) with Python under Python 3.10 ?
Thank you.

@kevin-dietz
Copy link

@vea-therese it installs fine using pipenv, so I see no reason why it wouldn’t install in other virtual environment setups

@vea-therese
Copy link

@vea-therese it installs fine using pipenv, so I see no reason why it wouldn’t install in other virtual environment setups

I've tried pip install and cloning but it still won't work. Though I haven't tried downgrading my python version, I currently have 3.10

@kevin-dietz
Copy link

@vea-therese Others have mentioned it won’t install properly on 3.10 but should install fine on <= 3.9

@pgr123
Copy link
Author

pgr123 commented Nov 12, 2022

That is true but how can I change the Python 3.10 do downgrade to Python 3.9. And I must reinstall all my python packages and the problem is that Ubuntu 22.04.1 use Python 3.10.6 so it is used by the OS and I cannot change it. What can I do ?
Thank you.

@vea-therese
Copy link

@vea-therese Others have mentioned it won’t install properly on 3.10 but should install fine on <= 3.9

I downgraded my global python to 3.7, it still didn't work. I tried 3.7 because I was able to install pyearth in a conda environment with a 3.7 python weeks ago. That's why I'm wondering if it is possible to connect a virtual environment or the Django project into my conda environment with pyearth.

@vea-therese
Copy link

That is true but how can I change the Python 3.10 do downgrade to Python 3.9. And I must reinstall all my python packages and the problem is that Ubuntu 22.04.1 use Python 3.10.6 so it is used by the OS and I cannot change it. What can I do ?
Thank you.

if you're using conda, I just typed: conda install python=3.7 or 3.9 since that's the version that you prefer.

Though if you're referring to the global python, I just uninstalled the 3.10 and installed 3.7. I use Windows, I'm not familiar with Ubuntu.

@pgr123
Copy link
Author

pgr123 commented Nov 12, 2022

Thank you, I don't use conda.
Maybe, I must install it (or anaconda) but I don't know how install and use it on Ubuntu.
And is it sure that py-earth will work with it ?
Seen the big changes in Python 3.10, I think it should have been called Python 4 (LOL !)

@kevin-dietz
Copy link

I downgraded my global python to 3.7, it still didn't work. I tried 3.7 because I was able to install pyearth in a conda environment with a 3.7 python weeks ago. That's why I'm wondering if it is possible to connect a virtual environment or the Django project into my conda environment with pyearth.

@vea-therese Here is a code snippet to try to install it in a virtual environment.

git clone https://github.com/jcrudy/py-earth.git
cd py-earth  

pipenv run $(pipenv --venv)/bin/python setup.py build_ext --inplace --cythonize

mv pyearth $(pipenv --venv)/lib/python3.9/site-packages

If that doesn't work, this docker image may help you install py-earth into a virtual environment: https://gitlab.com/gitlab-data/data-science

@pgr123
Copy link
Author

pgr123 commented Nov 12, 2022

Thank you, I'll try that tomorrow.

@vea-therese
Copy link

I forgot to thank u @kevin-dietz it worked! We're now presenting our thesis.

@pgr123
Copy link
Author

pgr123 commented Nov 19, 2022

Good morning,
I managed to compile py-earth with Python 3.10.
After
git clone https://github.com/jcrudy/py-earth.git
cd py-earth
and we must modify the files utils.c and types.c and changes the "exc_" with "curexc_".
Then the compilation works and the packages works in Python 3.10 !!!! Good news ! And no need of virtual environment !
Thanks to all. Have a good day.

@pgr123 pgr123 closed this as completed Nov 19, 2022
@evertonsantanaj
Copy link

Good morning, I managed to compile py-earth with Python 3.10. After git clone https://github.com/jcrudy/py-earth.git cd py-earth and we must modify the files utils.c and types.c and changes the "exc_" with "curexc_". Then the compilation works and the packages works in Python 3.10 !!!! Good news ! And no need of virtual environment ! Thanks to all. Have a good day.

Thank you! Just an addition, I had to replace "exc_" with "curexc_" for the other .c files as well and using python setup.py install --cythonize

@vancities
Copy link

vancities commented Apr 25, 2023

I downgraded my global python to 3.7, it still didn't work. I tried 3.7 because I was able to install pyearth in a conda environment with a 3.7 python weeks ago. That's why I'm wondering if it is possible to connect a virtual environment or the Django project into my conda environment with pyearth.

@vea-therese Here is a code snippet to try to install it in a virtual environment.

git clone https://github.com/jcrudy/py-earth.git
cd py-earth  

pipenv run $(pipenv --venv)/bin/python setup.py build_ext --inplace --cythonize

mv pyearth $(pipenv --venv)/lib/python3.9/site-packages

If that doesn't work, this docker image may help you install py-earth into a virtual environment: https://gitlab.com/gitlab-data/data-science

@kevin-dietz the analytics image in your repo seems based on Python 3.7. What is the minor version of 3.9 or cython version you have to make it work? I could not compile on Linux based system. Thanks.

@kevin-dietz
Copy link

@vancities we have stopped supporting py-earth in our image because the package has not been updated in 5.5 years.

@pgr123
Copy link
Author

pgr123 commented Apr 25, 2023

I succeeded in running py-earth with Python 3.10 with few modifs and it works well !
If somebody want to know how to do, tell me.
Excuse my bad English.
Pascal

@Williamz4lyf
Copy link

Hi, how did you do this?

@pgr123
Copy link
Author

pgr123 commented Apr 27, 2023

Hi Williamz4lyf,
You must change something in the sources, so :
git clone https://github.com/jcrudy/py-earth.git
cd py-earth
then you must replace all the "exc_" with "curexc_" in the files _utils.c and _types.c
and compile with
python setup.py build_ext --inplace --cythonize
and then move the obtained (corrected) directory pyearth to your directory /lib/python3/dist-packages with
mv pyearth /lib/python3/dist-packages
and this is all !
If you want I can send the corrected directory pyearth.
Have a good day.

@vancities
Copy link

Hi Williamz4lyf, You must change something in the sources, so : git clone https://github.com/jcrudy/py-earth.git cd py-earth then you must replace all the "exc_" with "curexc_" in the files _utils.c and _types.c and compile with python setup.py build_ext --inplace --cythonize and then move the obtained (corrected) directory pyearth to your directory /lib/python3/dist-packages with mv pyearth /lib/python3/dist-packages and this is all ! If you want I can send the corrected directory pyearth. Have a good day.

Hi pgr123, could you share which numpy and cython version do you use? If you could share correctred directory, it would be wonderful. @evertonsantanaj mentioned that there are more .c files needed to be changed.

@pgr123
Copy link
Author

pgr123 commented May 2, 2023

Hi vancities, I use numpy 1.23.3 and cython 0.29.14.
(Yes you must change all the exc_ in all the c files.)
Here my modified compiled directory pyearth. You have just to unzip and copy it in /lib/python3/dist-packages :
pyearth.zip
(I use Linux Ubuntu 22.04 and Mint 21.1)
Excuse my bad english.

@vancities
Copy link

vancities commented May 22, 2023

Hi @pgr123,

Thanks for your reply and sharing. Do you happen to still have the files that before compilation(the repo you made modification before running python setup.py build_ext --inplace --cythonize)? It would be helpful for people to compile with the modified files on different platforms. Btw, I assume your base files are from master branch instead of the more recent 0.2dev branch?

Hi vancities, I use numpy 1.23.3 and cython 0.29.14. (Yes you must change all the exc_ in all the c files.) Here my modified compiled directory pyearth. You have just to unzip and copy it in /lib/python3/dist-packages : pyearth.zip (I use Linux Ubuntu 22.04 and Mint 21.1) Excuse my bad english.

@gb07bh
Copy link

gb07bh commented Jun 10, 2023

@pgr123 It would be helpful if you could just zip the modified files, as stated by @vancities .

@pgr123
Copy link
Author

pgr123 commented Jun 10, 2023

Here is the corrected version of the modified files for pYTHON 3.10. I hope that help.
pyearth modified files.zip

@gb07bh
Copy link

gb07bh commented Oct 17, 2023

Thank you very much @pgr123 !

@pgr123
Copy link
Author

pgr123 commented Oct 17, 2023

With pleasure !
Have a good day.

@twistfire
Copy link

twistfire commented Nov 28, 2023

@pgr123 can you help me to resolve the issue I have with installing this package?
It seems that my Cython or something is wrong. I did exactly like you described. in my virtualenvironment installed numpy and Cython using pip, python 3.10.6.
cloned the repository

git clone https://github.com/jcrudy/py-earth.git

replaced files with modified versions you have provided in pyearth.zip..

But then, it can't compilate files using Cython?
Can you help to resolve that issue?

(.venv) fire@note-4:/py_projects/ATARI_YW_LM$ git clone https://github.com/jcrudy/py-earth.git
Cloning into 'py-earth'...
remote: Enumerating objects: 3723, done.
remote: Total 3723 (delta 0), reused 0 (delta 0), pack-reused 3723
Receiving objects: 100% (3723/3723), 19.17 MiB | 4.33 MiB/s, done.
Resolving deltas: 100% (2719/2719), done.
(.venv) fire@note-4:
/py_projects/ATARI_YW_LM$ cd py-earth/
(.venv) fire@note-4:~/py_projects/ATARI_YW_LM/py-earth$ python setup.py build_ext --inplace --cythonize
Compiling pyearth/_util.pyx because it changed.
Compiling pyearth/_basis.pyx because it changed.
Compiling pyearth/_record.pyx because it changed.
Compiling pyearth/_pruning.pyx because it changed.
Compiling pyearth/_forward.pyx because it changed.
Compiling pyearth/_knot_search.pyx because it changed.
Compiling pyearth/_qr.pyx because it changed.
Compiling pyearth/_types.pyx because it changed.
[1/8] Cythonizing pyearth/_basis.pyx
/home/fire/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /home/fire/py_projects/ATARI_YW_LM/py-earth/pyearth/_basis.pxd
tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:

...
from cpython cimport bool
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t
^

pyearth/_basis.pxd:3:0: '_types.pxd' not found

Error compiling Cython file:

...
from cpython cimport bool
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t
^

pyearth/_basis.pxd:3:0: '_types/FLOAT_t.pxd' not found

Error compiling Cython file:

...
from cpython cimport bool
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t
^

pyearth/_basis.pxd:3:0: '_types/INT_t.pxd' not found

Error compiling Cython file:

...
from cpython cimport bool
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t
^

pyearth/_basis.pxd:3:0: '_types/INDEX_t.pxd' not found

Error compiling Cython file:

...
from cpython cimport bool
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t
^

pyearth/_basis.pxd:3:0: '_types/BOOL_t.pxd' not found

Error compiling Cython file:

...

cpdef bint make_unsplittable(BasisFunction self)

cpdef list get_children(BasisFunction self)

cpdef BasisFunction get_coverage(BasisFunction self, INDEX_t variable)
                                                     ^

pyearth/_basis.pxd:31:57: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...

cpdef list get_children(BasisFunction self)

cpdef BasisFunction get_coverage(BasisFunction self, INDEX_t variable)

cpdef bool has_linear(BasisFunction self, INDEX_t variable)
                                          ^

pyearth/_basis.pxd:33:46: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...

cpdef BasisFunction get_coverage(BasisFunction self, INDEX_t variable)

cpdef bool has_linear(BasisFunction self, INDEX_t variable)

cpdef bool linear_in(BasisFunction self, INDEX_t variable)
                                         ^

pyearth/_basis.pxd:35:45: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...

cpdef prune(BasisFunction self)

cpdef unprune(BasisFunction self)

cpdef knots(BasisFunction self, INDEX_t variable)
                                ^

pyearth/_basis.pxd:47:36: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...

cpdef unprune(BasisFunction self)

cpdef knots(BasisFunction self, INDEX_t variable)

cpdef INDEX_t effective_degree(BasisFunction self)
      ^

pyearth/_basis.pxd:49:10: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...

cpdef knots(BasisFunction self, INDEX_t variable)

cpdef INDEX_t effective_degree(BasisFunction self)

cpdef apply(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=2] X,
                                            ^

pyearth/_basis.pxd:51:48: Invalid type.

Error compiling Cython file:

...
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t

cdef FLOAT_t log2(FLOAT_t x)
^

pyearth/_util.pxd:4:5: 'FLOAT_t' is not a type identifier

Error compiling Cython file:

...
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t

cdef FLOAT_t log2(FLOAT_t x)
^

pyearth/_util.pxd:4:18: 'FLOAT_t' is not a type identifier

Error compiling Cython file:

...
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t

cdef FLOAT_t log2(FLOAT_t x)

cpdef apply_weights_2d(cnp.ndarray[FLOAT_t, ndim=2] B,
^

pyearth/_util.pxd:6:35: Invalid type.

Error compiling Cython file:

...

cython: cdivision = True

cython: boundscheck = False

cython: wraparound = False

cython: profile = False

from ._util cimport log2, apply_weights_2d
^

pyearth/_basis.pyx:7:0: 'pyearth/_util/apply_weights_2d.pxd' not found

Error compiling Cython file:

...

from ._util cimport log2, apply_weights_2d
from libc.math cimport log
from libc.math cimport abs
cimport cython
cdef FLOAT_t ZERO_TOL = 1e-16
^

pyearth/_basis.pyx:11:5: 'FLOAT_t' is not a type identifier

Error compiling Cython file:

...
self.splittable = False

cpdef list get_children(BasisFunction self):
    return self.children

cpdef BasisFunction get_coverage(BasisFunction self, INDEX_t variable):
                                                     ^

pyearth/_basis.pyx:112:57: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...
for child in self.get_children():
if child.covered(variable):
return child
return None

cpdef bool has_linear(BasisFunction self, INDEX_t variable):
                                          ^

pyearth/_basis.pyx:119:46: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...
for child in self.get_children():
if child.linear_in(variable):
return True
return False

cpdef bool linear_in(BasisFunction self, INDEX_t variable):
                                         ^

pyearth/_basis.pyx:126:45: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...
self.pruned = True

cpdef unprune(BasisFunction self):
    self.pruned = False

cpdef knots(BasisFunction self, INDEX_t variable):
                                ^

pyearth/_basis.pyx:153:36: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...
child = self.get_children()[idx]
if child.has_knot():
result.append(child.get_knot_idx())
return result

cpdef INDEX_t effective_degree(BasisFunction self):
      ^

pyearth/_basis.pyx:172:10: 'INDEX_t' is not a type identifier

Error compiling Cython file:

...
data_dict[k] += missing_dict[k] - 1
else:
data_dict[k] = missing_dict[k]
return sum(data_dict.values())

cpdef apply(BasisFunction self, cnp.ndarray[FLOAT_t, ndim=2] X,
                                            ^

pyearth/_basis.pyx:184:48: Invalid type.
Traceback (most recent call last):
File "/home/fire/py_projects/ATARI_YW_LM/py-earth/setup.py", line 165, in
setup_package()
File "/home/fire/py_projects/ATARI_YW_LM/py-earth/setup.py", line 161, in setup_package
setup_args['ext_modules'] = get_ext_modules()
File "/home/fire/py_projects/ATARI_YW_LM/py-earth/setup.py", line 22, in get_ext_modules
ext_modules = cythonize(
File "/home/fire/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
cythonize_one(*args)
File "/home/fire/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pyearth/_basis.pyx

@pgr123
Copy link
Author

pgr123 commented Nov 28, 2023

The problem is that pyearth does not work with the new new versions of numpy and scipy so what I have do is to install the good versions with
pip3 install numpy==1.21.5 & pip3 install scipy==1.10.1
and then pyearth works.
Otherwise, you must use earth with R by means of rpy2 but you must know a little R to do that.
I am sorry but with numpy==1.21.5 and scipy==1.10.1 pyearth works fine.
Have a good day.
Best regards.

@twistfire
Copy link

The problem is that pyearth does not work with the new new versions of numpy and scipy so what I have do is to install the good versions with pip3 install numpy==1.21.5 & pip3 install scipy==1.10.1 and then pyearth works. Otherwise, you must use earth with R by means of rpy2 but you must know a little R to do that. I am sorry but with numpy==1.21.5 and scipy==1.10.1 pyearth works fine. Have a good day. Best regards.

installed the versions you mentioned, but still the same issue:

(.venv) fire@note-4:~/py_projects/ATARI_YW_LM/py-earth$ python setup.py build_ext --inplace --cythonize
Compiling pyearth/_util.pyx because it changed.
Compiling pyearth/_basis.pyx because it changed.
Compiling pyearth/_record.pyx because it changed.
Compiling pyearth/_pruning.pyx because it changed.
Compiling pyearth/_forward.pyx because it changed.
Compiling pyearth/_knot_search.pyx because it changed.
Compiling pyearth/_qr.pyx because it changed.
Compiling pyearth/_types.pyx because it changed.
[1/8] Cythonizing pyearth/_basis.pyx
/home/fire/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /home/fire/py_projects/ATARI_YW_LM/py-earth/pyearth/_basis.pxd
tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:

...
from cpython cimport bool
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t
^

pyearth/_basis.pxd:3:0: '_types.pxd' not found

Error compiling Cython file:

...
from cpython cimport bool
cimport numpy as cnp
from _types cimport FLOAT_t, INT_t, INDEX_t, BOOL_t
^

do not know what to do with this. Maybe it's because of the Cythonization?

@pgr123
Copy link
Author

pgr123 commented Nov 28, 2023

Yes, surely, but you don't need to recompile the sources. You have just to copy the directory pyearth of my zip in /usr/lib/python3/dist-packages if you use Linux. On windows, you must search where is the directory dist-packages for python3 and copy here. I don't use Windows so I do not know where it is.
If you don't find my directory pyearth in my zip, I can resend it.
See my comment on May 2.

@pgr123
Copy link
Author

pgr123 commented Nov 28, 2023

I use now Python 3.10 and my version of pyearth works well.

@twistfire
Copy link

twistfire commented Nov 28, 2023

I use Ubuntu 22.04.2 LTS under WSL.

Copied unzipped your paskage folder to my virtual environment: .venv/lib/python3.10/site-packages

When trying to import this I got next:
from pyearth import Earth


AttributeError Traceback (most recent call last)
..fit_and_elim.ipynb Cell 7 line 1
----> 1 from pyearth import Earth

File ~/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/pyearth/init.py:6
1 '''
2 Created on Feb 16, 2013
3
4 @author: jasonrudy
5 '''
----> 6 from .earth import Earth
8 from ._version import get_versions
9 version = get_versions()['version']

File ~/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/pyearth/earth.py:1
----> 1 from ._forward import ForwardPasser
2 from ._pruning import PruningPasser, FEAT_IMP_CRITERIA
3 from ._util import ascii_table, apply_weights_2d, gcv

File ~/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/pyearth/_forward.pyx:1, in init pyearth._forward()

File ~/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/pyearth/_basis.pyx:12, in init pyearth._basis()

File ~/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/pyearth/_types.pyx:3, in init pyearth._types()
1 import numpy as np
2 FLOAT = np.float64
----> 3 INT = np.int
4 INDEX = np.intp
5 BOOL = np.uint8

File ~/py_projects/ATARI_YW_LM/.venv/lib/python3.10/site-packages/numpy/init.py:324, in getattr(attr)
319 warnings.warn(
320 f"In the future np.{attr} will be defined as the "
321 "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
323 if attr in former_attrs:
--> 324 raise AttributeError(former_attrs[attr])
326 if attr == 'testing':
327 import numpy.testing as testing

AttributeError: module 'numpy' has no attribute 'int'.
np.int was a deprecated alias for the builtin int. To avoid this error in existing code, use int by itself. Doing this will not modify any behavior and is safe. When replacing np.int, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

numpy version installed 1.21.25...
Sorry for disturbing you a lot, it seems that you are the only one who solved it.. :) thanks for helping me & community as well.

@pgr123
Copy link
Author

pgr123 commented Nov 28, 2023

I use also Ubuntu 22.04 and it works.
I don't use virtual environment.
Surely, your directory .venv/lib/python3.10/site-packages is not the good one. Where is the directory dist-packages ?
Try to copy to /usr/lib/python3/dist-packages.
It is late in France, so we can continue tomorrow if you want.
It's a pleasure for me to contribute.

@twistfire
Copy link

Unfortunately I need to work within virtualenvironment for this project.

I suppose that for my case moving to my virtualenvironment directory (/..../path_to_project/.venv/lib/python3.10/site-packages) it's the same as you suggest for global environment... Because VE is isolated.

and we can see that error appears when we import a package which was unzipped. and pylance sees the package... but some issues with data types appear.
will think until tomorrow..
I can't find any alternatives to that library.

@pgr123
Copy link
Author

pgr123 commented Nov 29, 2023

It seems you use numpy 1.21.25 and have you tried with the version I recommanded (numpy 1.21.5) ?
It works with numpy 1.21.5 and scipy 1.10.1.
Do
pip3 install numpy==1.21.5 & pip3 install scipy==1.10.1
and tell me if that work.

@pgr123
Copy link
Author

pgr123 commented Nov 30, 2023

Hello twistfire, did you succeed ?

@twistfire
Copy link

Hello @pgr123 thanks for your interest. will test today evening and report here. But found that it's not recommended to use this package with python >3.6 .. but in my project i have to use at least 3.10, maybe can downgrade to 3.9.. So will write.

@pgr123
Copy link
Author

pgr123 commented Nov 30, 2023

Where have you seen that it's not recommended to use this package with python >3.6 ? I don't see why ? What is the reason ?

@pgr123
Copy link
Author

pgr123 commented Dec 2, 2023

Hello twistfire,
I'm glad to know that your problem wasn't so urgent after all !
With version 1.21.5 of numpy everything works !
Have a nice week end.

@twistfire
Copy link

twistfire commented Dec 3, 2023

@pgr123
Sorry for the late reply. I had an issue with my internet - someone broke my cable, I hadn't internet until today :(

About Python 3.6 and compatibility/dependencies - I googled all the info I could and one of the guys who showed nice results plots commented for a guy who wanted to use it with python 3.9 that he should use 3.6 instead to use compatibility.. (can't find it again).. Nevertheless. I have downgraded the version of numpy to 1.21.5 and broke my current project - I have to use the newest version of numpy there.. because of the pandas dependencies...

But when I created a "clean" Python 3.10.6 virtual environment and installed it all from scratch + -> it worked (!!) - exactly like you suggested. Now I am thinking about how to find a pandas version to work with my hdf5 datasets and use numpy version 1.21.5... :( if it's possible of course.

Here is some result as a test.
mars_fit_res_example

So thank you very much for your tries and support!!!

However, it seems that this automated approach is not working like I want for my task... E.g. here is the model data I have - blue dots, and as a fit-result, I got something very poor.... While experiments with the initial demo datasets work well enough. It seems that I need to find and tune some parameters for the fitter - to be more sensitive and catch the signal form I have..

mars_fit_res_syn_data

Again, thank you for your efforts and support!

@pgr123
Copy link
Author

pgr123 commented Dec 4, 2023

If you want, you can use Orange data mining (https://orangedatamining.com/), there is an addon to do MARS (earth) model and there are many other things interesting.

@twistfire
Copy link

@pgr123 Thanks! Did you use the Orange package? I have tried on a local machine and it seems MARS is not provided...

@pgr123
Copy link
Author

pgr123 commented Dec 4, 2023

It seems that this is an addon (https://orangedatamining.com/blog/earth-multivariate-adaptive-regression-splines/) that you must add to orange3. I did not tried it. Say me if you find how it works.

@evertonsantanaj
Copy link

I was having the same problems as @twistfire installing in mac and a venv with Python 3.11.

A configuration that worked for me:
pip install ipykernel
pip install openpyxl
pip install matplotlib
pip install pandas
pip install numpy==1.26.2
pip install scipy==1.10.1
pip install Cython==0.29.36

And after that:
python setup.py install --cythonize

I just needed to further adjust some parts in the code that used deprecated versions for int and float in numpy.

py-earth-master_backup_np copy.zip
(please, rename the folder to py-earth before using it)

Thank you for all the comments and discussions here, special kudos to @pgr123 !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants