pyopengl icon indicating copy to clipboard operation
pyopengl copied to clipboard

Unable to load numpy_formathandler when install from wheel

Open Czaki opened this issue 4 years ago • 7 comments

When using PyOpenGL-acceleratein version 3.1.5 from wheel there shown this warning:

OpenGL.arrays.numpymodule:Unable to load numpy_formathandler accelerator from OpenGL_accelerate

When install it from source

pip install PyOpenGL-accelerate  --no-binary :all:

This warning does not shown. There is some error in building wheel process?

Czaki avatar Jul 01 '20 09:07 Czaki

Could you provide details such as:

  • what operating system (I'm assuming either 32 or 64 bit windows)
  • what python release (e.g. is it the python.org version or anaconda install)
  • what python version (2.7, 3.6, 3.7, etc)

Also, if you could run this:

python3.7 -c "from OpenGL_accelerate import numpy_formathandler"

from the console and post the traceback, it would help me understand if the install failed or if there's a problem with the code.

mcfletch avatar Jul 19 '20 15:07 mcfletch

Windows 10 64 bit (There is no wheel for other system than windows on pypi.org) Python 3.7.3 from python.org

python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Command output:

>python -c "from OpenGL_accelerate import numpy_formathandler"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'numpy_formathandler' from 'OpenGL_accelerate' (C:\Users\Grzesiek\PycharmProjects\napari\venv\lib\site-packages\OpenGL_accelerate\__init__.py)

Whole __init__.py

"""Cython-coded accelerators for the PyOpenGL wrapper

This package contains Cython accelerator modules which
attempt to speed up certain aspects of the PyOpenGL 3.x
wrapper mechanism.  The source code is part of the
PyOpenGL package and is built via the setupaccel.py
script in the top level of the PyOpenGL source package.
"""
__version__ = '3.1.5'
__version_tuple__ = (3,1,5)

Czaki avatar Jul 20 '20 19:07 Czaki

Same problem on macOS 10.15.6 with PyOpenGL 3.1.5 and PyOpenGL_accelerate 3.1.5 with installed from PyPi using Python 3.8.5 with python compiled from source.

pip install PyOpenGL==3.1.5 PyOpenGL-accelerate==3.1.5

The PyOpenGL_accelerate does not have numpy_formathandler

/Users/goddard/ucsf/chimerax/ChimeraX.app/Contents/lib/python3.8/site-packages/OpenGL_accelerate: total used in directory 2336 available 9764447404 drwxr-xr-x 12 goddard staff 384 Sep 24 20:03 . drwxr-xr-x 354 goddard staff 11328 Sep 27 12:41 .. -rw-r--r-- 1 goddard staff 379 Sep 24 19:56 init.py drwxr-xr-x 3 goddard staff 96 Sep 24 20:03 pycache -rwxr-xr-x 1 goddard staff 297840 Sep 24 19:56 arraydatatype.cpython-38-darwin.so -rwxr-xr-x 1 goddard staff 80876 Sep 24 19:56 buffers_formathandler.cpython-38-darwin.so -rwxr-xr-x 1 goddard staff 72920 Sep 24 19:56 errorchecker.cpython-38-darwin.so -rwxr-xr-x 1 goddard staff 77728 Sep 24 19:56 formathandler.cpython-38-darwin.so -rwxr-xr-x 1 goddard staff 66416 Sep 24 19:56 latebind.cpython-38-darwin.so -rwxr-xr-x 1 goddard staff 53012 Sep 24 19:56 nones_formathandler.cpython-38-darwin.so -rwxr-xr-x 1 goddard staff 182416 Sep 24 19:56 vbo.cpython-38-darwin.so -rwxr-xr-x 1 goddard staff 349988 Sep 24 19:56 wrapper.cpython-38-darwin.so

so OpenGL/arrays/numpymodule.py gives the warning "Unable to load numpy_formathandler accelerator from OpenGL_accelerate".

Is there an installation dependency where numpy has to be installed for the numpy_formathandler library to be included? I would think PyOpenGL_accelerate would have a dependency on numpy so this would not be a problem.

tomgoddard avatar Sep 27 '20 20:09 tomgoddard

On macOS PyOpenGL-accelerate 3.1.5 from PyPi has to be compiled and if numpy has not already been installed it does not create the numpy_formathandler module. The solution is to make sure numpy is installed before PyOpenGL-accelerate.

If PyOpenGL-accelerate has already been installed first it must be uninstalled

pip uninstall PyOpenGL-accelerate

and also pip caches compiled wheels so it is also necessary to remove the cached compiled version

pip cache remove PyOpenGL*

Then

pip install numpy pip install PyOpenGL-accelerate

Possibly PyOpenGL-accelerate should specify a dependency on numpy. There is a way to specify optional dependencies using PEP 518 pyproject.toml file, but PyOpenGL is using the older setup.py method for declaring dependencies.

tomgoddard avatar Dec 10 '20 01:12 tomgoddard

On macOS PyOpenGL-accelerate 3.1.5 from PyPi has to be compiled and if numpy has not already been installed it does not create the numpy_formathandler module. The solution is to make sure numpy is installed before PyOpenGL-accelerate.

On macOS and Linux this package is installed from the source. So the order of install is important. On Windows, it is installed from the wheel and the packaging pipeline should be fixed.

Possibly PyOpenGL-accelerate should specify a dependency on numpy. There is a way to specify optional dependencies using PEP 518 pyproject.toml file, but PyOpenGL is using the older setup.py method for declaring dependencies.

setup.py allows specifying optional dependencies using extras_require.

Czaki avatar Dec 10 '20 02:12 Czaki

The binary PyOpenGL-accelerate 3.1.5 wheel for Python 3.8 on PyPi is missing the numpy_formathandler library. Apparently the PyPi version was compiled without numpy.

$ unzip -l ~/Downloads/PyOpenGL_accelerate-3.1.5-cp38-cp38-win_amd64.whl Archive: /Users/goddard/Downloads/PyOpenGL_accelerate-3.1.5-cp38-cp38-win_amd64.whl Length Date Time Name


  379  01-04-2020 02:27   OpenGL_accelerate/__init__.py

220160 01-04-2020 02:27 OpenGL_accelerate/arraydatatype.cp38-win_amd64.pyd 64512 01-04-2020 02:27 OpenGL_accelerate/buffers_formathandler.cp38-win_amd64.pyd 58368 01-04-2020 02:27 OpenGL_accelerate/errorchecker.cp38-win_amd64.pyd 61440 01-04-2020 02:27 OpenGL_accelerate/formathandler.cp38-win_amd64.pyd 54272 01-04-2020 02:27 OpenGL_accelerate/latebind.cp38-win_amd64.pyd 43520 01-04-2020 02:27 OpenGL_accelerate/nones_formathandler.cp38-win_amd64.pyd 140800 01-04-2020 02:27 OpenGL_accelerate/vbo.cp38-win_amd64.pyd 249344 01-04-2020 02:27 OpenGL_accelerate/wrapper.cp38-win_amd64.pyd 932 01-04-2020 02:27 PyOpenGL_accelerate-3.1.5.dist-info/METADATA 105 01-04-2020 02:27 PyOpenGL_accelerate-3.1.5.dist-info/WHEEL 1711 01-04-2020 02:27 PyOpenGL_accelerate-3.1.5.dist-info/license.txt 18 01-04-2020 02:27 PyOpenGL_accelerate-3.1.5.dist-info/top_level.txt 1394 01-04-2020 02:27 PyOpenGL_accelerate-3.1.5.dist-info/RECORD


896955 14 files

Also missing from PyOpenGL_accelerate-3.1.5-cp37-cp37m-win_amd64.whl.

Probably all the 3.1.5 builds were done without numpy and so are missing numpy_formathandler.

tomgoddard avatar Dec 11 '20 04:12 tomgoddard

Hi, i can solve a similar problem (the same error) upgrading the librarys

pip install PyOpenGL_accelerate --upgrade pip install numpy --upgrade

and Its Done!

Gantrax2 avatar Dec 31 '22 13:12 Gantrax2