Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue installing ffnet with python 3.12 #10

Closed
mathomp4 opened this issue Mar 20, 2024 · 6 comments
Closed

Issue installing ffnet with python 3.12 #10

mathomp4 opened this issue Mar 20, 2024 · 6 comments

Comments

@mathomp4
Copy link
Contributor

I recently tried to install ffnet from this repo and I got:

7366   │ Collecting git+https://github.com/mrkwjc/ffnet
7367   │   Cloning https://github.com/mrkwjc/ffnet to /tmp/pip-req-build-r4u80rit
7368   │   Running command git clone --filter=blob:none --quiet https://github.com/mrkwjc/ffnet /tmp/pip-req-build-r4u80rit
7369   │   Resolved https://github.com/mrkwjc/ffnet to commit 0759200adb0ca6544874fa233da4f12f04dee228
7370   │   Preparing metadata (setup.py): started
7371   │   Preparing metadata (setup.py): finished with status 'done'
7372   │ Building wheels for collected packages: ffnet
7373   │   Building wheel for ffnet (setup.py): started
7374   │   Building wheel for ffnet (setup.py): finished with status 'error'
7375   │   error: subprocess-exited-with-error
7376   │
7377   │   × python setup.py bdist_wheel did not run successfully.
7378   │   │ exit code: 1
7379   │   ╰─> [6 lines of output]
7380   │       Traceback (most recent call last):
7381   │         File "<string>", line 2, in <module>
7382   │         File "<pip-setuptools-caller>", line 34, in <module>
7383   │         File "/tmp/pip-req-build-r4u80rit/setup.py", line 26, in <module>
7384   │           from numpy.distutils.core import setup
7385   │       ModuleNotFoundError: No module named 'numpy.distutils'
7386   │       [end of output]
7387   │
7388   │   note: This error originates from a subprocess, and is likely not a problem with pip.
7389   │   ERROR: Failed building wheel for ffnet
7390   │   Running setup.py clean for ffnet
7391   │ Failed to build ffnet
7392   │ ERROR: Could not build wheels for ffnet, which is required to install pyproject.toml-based projects

If I try this command with python3.11 I see:

$ python3 --version
Python 3.11.6
$ python3 -c 'from numpy.distutils.core import setup'
<string>:1: DeprecationWarning:

  `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
  of the deprecation of `distutils` itself. It will be removed for
  Python >= 3.12. For older Python versions it will remain present.
  It is recommended to use `setuptools < 60.0` for those Python versions.
  For more details, see:
    https://numpy.org/devdocs/reference/distutils_status_migration.html

and with python3.12:

$ python3 --version
Python 3.12.2
mathomp4@discover31 ~
$ python3 -c 'from numpy.distutils.core import setup'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy.distutils'

As the message says, it looks like numpy.distutils is now gone and they recommend looking at:

https://numpy.org/devdocs/reference/distutils_status_migration.html

and unfortunately it looks like setuptools does not have Fortran support, so this might mean a move to meson. I see many people having to do this on GitHub (see scipy/scipy#13615). If I had a choice, I'd prefer CMake if only because I don't think meson is installed on any of my machines (but maybe with pip this doesn't matter?). Though looking at things like scikit-fmm/scikit-fmm#78 (comment), maybe meson is "winning"...

@mrkwjc
Copy link
Owner

mrkwjc commented Mar 21, 2024

Hi! Thanks for reporting! I pushed a solution with custom setuptools commands. Numpy (with f2py), meson and meson-python must be available at installation time. Does this work for you?

@mathomp4
Copy link
Contributor Author

Hi! Thanks for reporting! I pushed a solution with custom setuptools commands. Numpy (with f2py), meson and meson-python must be available at installation time. Does this work for you?

Ooh. Thanks! I'll let you know tomorrow...once I figure out how to install meson on the cluster. 😄

@mrkwjc
Copy link
Owner

mrkwjc commented Mar 22, 2024

meson is pip installable...

@mathomp4
Copy link
Contributor Author

Good news, it installs!

Bad news, I think more changes are needed underneath. When I try to load it:

$ python3 -c 'import ffnet'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/discover/nobackup/mathomp4/Miniconda-Test/MINIpyD/24.1.2-0_py3.12/2024-03-22/lib/python3.12/site-packages/ffnet/__init__.py", line 17, in <module>
    import ffnet.ffnet as ffnetmodule
  File "/discover/nobackup/mathomp4/Miniconda-Test/MINIpyD/24.1.2-0_py3.12/2024-03-22/lib/python3.12/site-packages/ffnet/ffnet.py", line 16, in <module>
    from scipy import zeros, ones, optimize, sqrt, ndarray, array
ImportError: cannot import name 'zeros' from 'scipy' (/discover/nobackup/mathomp4/Miniconda-Test/MINIpyD/24.1.2-0_py3.12/2024-03-22/lib/python3.12/site-packages/scipy/__init__.py)

I think these lines:

ffnet/ffnet/ffnet.py

Lines 16 to 17 in 67279ab

from scipy import zeros, ones, optimize, sqrt, ndarray, array
from numpy import random

need to become:

from numpy import zeros, ones, sqrt, ndarray, array
from scipy import optimize

If I do that, the README example works:

$ python3 ffnet_example.py
Feed-forward neural network:
inputs:     2
hiddens:    2
outputs:    1
connections and biases:    9

Testing results for 4 testing cases:
OUTPUT 1 (node nr 5):
Targets vs. outputs:
   1      1.000000      1.000000
   2      0.000000      0.500000
   3      0.000000      0.000001
   4      1.000000      0.499999
Regression line parameters:
slope         =  0.499999
intercept     =  0.250000
r-value       =  0.707106
p-value       =  0.292894
slope stderr  =  0.353553
estim. stderr =  0.353553

(or, I guess, doesn't crash? Not sure what the answer should be).

That said, it's possible my suggested changes might need to be protected with try/except? Not sure when the bits moved from scipy to numpy...

@mrkwjc
Copy link
Owner

mrkwjc commented Mar 23, 2024

Change must be introduced in >scipy-1.10... Nevertheless, I introduced your changes, without try/except, this always should be written so :)

@mathomp4
Copy link
Contributor Author

@mrkwjc Things seem to be working well for me now! Thanks! I'll close this.

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

No branches or pull requests

2 participants