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

Fix: numpy version for python 3.11 #839

Merged
merged 4 commits into from
May 31, 2023
Merged

Fix: numpy version for python 3.11 #839

merged 4 commits into from
May 31, 2023

Conversation

tomsweeting
Copy link
Contributor

Fix for issue #835

I encountered the same issue today. By updating to require numpy 1.24.3 I was about to build successfully for my environment (python 3.11.3 / macos ventura arm64 / gstreamer support enabled)

@asmorkalov
Copy link
Collaborator

According to https://numpy.org/news/ 1.23 is minimal Numpy version that supports Python 3.11.

setup.py Outdated
@@ -32,7 +32,7 @@ def main():
'numpy>=1.19.3; python_version>="3.6" and platform_system=="Linux" and platform_machine=="aarch64"',
'numpy>=1.21.0; python_version<="3.9" and platform_system=="Darwin" and platform_machine=="arm64"',
'numpy>=1.21.4; python_version>="3.10" and platform_system=="Darwin"',
"numpy>=1.22.0; python_version>='3.11'"
"numpy>=1.24.3; python_version>='3.11'"
Copy link
Collaborator

@asmorkalov asmorkalov May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you replace minimal version with 1.23.5?

pyproject.toml Outdated
@@ -10,5 +10,5 @@ requires = [
"numpy==1.19.3; python_version=='3.9' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.21.2; python_version=='3.10' and platform_system!='Darwin'",
"numpy==1.21.4; python_version=='3.10' and platform_system=='Darwin'",
"numpy==1.22.0; python_version>='3.11'"
"numpy==1.24.3; python_version>='3.11'"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let it be 1.23.0 to leverage numpy backward compatibility.

Copy link
Contributor Author

@tomsweeting tomsweeting May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it looks like there is a problem using 1.23.0 - I had a little time this evening to try building with this and I hit the same error again.

Start of output from pip wheel:

  Running command pip subprocess to install build dependencies
  Ignoring numpy: markers 'python_version == "3.6" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.7" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.8" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version <= "3.9" and sys_platform == "linux" and platform_machine == "aarch64"' don't match your environment
  Ignoring numpy: markers 'python_version <= "3.9" and sys_platform == "darwin" and platform_machine == "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.9" and platform_machine != "aarch64" and platform_machine != "arm64"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.10" and platform_system != "Darwin"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.10" and platform_system == "Darwin"' don't match your environment
  Collecting setuptools==59.2.0
    Using cached setuptools-59.2.0-py3-none-any.whl (952 kB)
  Collecting wheel==0.37.0
    Using cached wheel-0.37.0-py2.py3-none-any.whl (35 kB)
  Collecting cmake>=3.1
    Using cached cmake-3.26.3-py2.py3-none-macosx_10_10_universal2.macosx_10_10_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl (45.6 MB)
  Collecting pip
    Using cached pip-23.1.2-py3-none-any.whl (2.1 MB)
  Collecting scikit-build>=0.13.2
    Downloading scikit_build-0.17.5-py3-none-any.whl (82 kB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.9/82.9 kB 2.5 MB/s eta 0:00:00
  Collecting numpy==1.23.0
    Downloading numpy-1.23.0.tar.gz (10.7 MB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.7/10.7 MB 7.9 MB/s eta 0:00:00
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'error'
    error: subprocess-exited-with-error

    × Getting requirements to build wheel did not run successfully.
    │ exit code: 1
    ╰─> [105 lines of output]
        <string>:71: RuntimeWarning: NumPy 1.23.0 may not yet support Python 3.11.
        Running from numpy source directory.
        <string>:86: 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

However by setting this to 1.23.2 instead, I was able to build successfully (python 3.11.3 / M1 mac)

Would you accept setting this to 1.23.2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a little digging and yeah it looks like 1.23.2 is the first version to specifically support python 3.11: https://numpy.org/doc/stable/release/1.23.2-notes.html

With that, i'll update this one more time. Let me know if that's alright!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes,1.23.2 works! Thanks!

@tomsweeting
Copy link
Contributor Author

@asmorkalov fair points, thanks - updated now!

@rainmeterLotus
Copy link

rainmeterLotus commented Jul 18, 2023

pip install opencv-python
how to specify the numpy version
i have install numpy=1.24.0,but to install opencv-python ,setup.py still use numpy=1.22.2

@Illyen
Copy link

Illyen commented Aug 30, 2023

With python 3.11 I can't install via pip at the moment, likely because the change to pyproject.toml has been overwritten by a later commit so it is again 1.22.2
It's still correct in the setup.py though.

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

Successfully merging this pull request may close these issues.

4 participants