oracle / graalpython

A Python 3 implementation built on GraalVM
Other
1.21k stars 104 forks source link

Encounter error when installing numpy and pandas (Python 3.8.5 (GraalVM CE Native 21.0.0) #189

Closed madeinquant closed 1 year ago

madeinquant commented 3 years ago

When I compile graalpython -m ginstall install pandas or graalpython -m ginstall install numpy I got the following error, please comment how to fix the error. Thank you.

$ graalpython --version
Python 3.8.5 (GraalVM CE Native 21.0.0)
line 54, in __init__
  File "number.c", line 284, in array_power
  File "ufunc_object.c", line 4688, in ufunc_generic_call
  File "ufunc_object.c", line 3178, in PyUFunc_GenericFunction
  File "ufunc_type_resolution.c", line 180, in PyUFunc_DefaultTypeResolver
  File "ufunc_type_resolution.c", line 2028, in linear_search_type_resolver
  File "ufunc_type_resolution.c", line 1639, in ufunc_loop_matches
  File "convert_datatype.c", line 904, in PyArray_CanCastArrayTo
java.lang.AssertionError
msimacek commented 3 years ago

Hi @mvandervliet, thank you for the report. I could not reproduce the error by just installing pandas/numpy. Could you please provide a more detailed steps to reproduce? When exactly did it crash? Is the crash always reproducible? Which platform are you on?

mvandervliet commented 3 years ago

Hi @mvandervliet, thank you for the report. I could not reproduce the error by just installing pandas/numpy. Could you please provide a more detailed steps to reproduce? When exactly did it crash? Is the crash always reproducible? Which platform are you on?

Wrong user @msimacek, although this is of interest 😄 .

madeinquant commented 3 years ago

Installed graalpython in virtual environment. I have no idea what wrong I did. Please feel free to comment.

(.graal_venv) $ gu list
ComponentId              Version             Component name                Stability           Origin 
--------------------------------------------------------------------------------------------------------
js                       21.0.0              Graal.js                      -                   
graalvm                  21.0.0              GraalVM Core                  -                   
llvm-toolchain           21.0.0              LLVM.org toolchain            Supported           github.com
native-image             21.0.0              Native Image                  Early adopter       github.com
python                   21.0.0              Graal.Python                  Experimental        github.com
ruby                     21.0.0              TruffleRuby                   Experimental        github.com
(.graal_venv) $ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
(.graal_venv) $ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  1. create a virtual environment first, graalpython -m venv ~/.graal_venv

  2. Activate the virtual environment source ~/.graal_venv/bin/activate

  3. graalpython checking

    $ graalpython --version
    Python 3.8.5 (GraalVM CE Native 21.0.0)
  4. install numpy and pandas in the virtual environment

    graalpython -m ginstall install pandas
    graalpython -m ginstall install numpy
msimacek commented 3 years ago

You didn't do anything wrong, the steps look correct to me. I couldn't reproduce the problem on Linux and @tstupka couldn't reproduce the problem on his Mac either. Could you please try to run this in your virtualenv: graalpython --python.WithJavaStacktrace=2 -m ginstall install numpy? It should produce more output that could help us diagnose the problem.

madeinquant commented 3 years ago

Created a new virtualenv (.graalenv) for testing, unfortunately, encountered same errors.


(.graalenv) MacBookPro: $ graalpython --python.WithJavaStacktrace=2 -m ginstall install numpy
Traceback (most recent call last):
  "<string>", line 1, in <module>
  "/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.0.0/Contents/Home/languages/python/lib-python/3/runpy.py", line 194, in _run_module_as_main
  "/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.0.0/Contents/Home/languages/python/lib-python/3/runpy.py", line 87, in _run_code
  "/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.0.0/Contents/Home/languages/python/lib-graalpython/modules/ginstall.py", line 668, in <module '/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.0.0/Contents/Home/languages/python/lib-graalpython/modules/ginstall.py'>
  "/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.0.0/Contents/Home/languages/python/lib-graalpython/modules/ginstall.py", line 661, in main
  "/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.0.0/Contents/Home/languages/python/lib-graalpython/modules/ginstall.py", line 88, in wrapper
  "/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.0.0/Contents/Home/languages/python/lib-python/3/importlib/__init__.py", line 127, in import_module
  "/Users/nelson/.graalenv/lib/python3.8/site-packages/numpy-1.16.4-py3.8-macosx-10.14-x86_64.egg/numpy/__init__.py", line 167, in <module '/Users/nelson/.graalenv/lib/python3.8/site-packages/numpy-1.16.4-py3.8-macosx-10.14-x86_64.egg/numpy/__init__.py'>
  "/Users/nelson/.graalenv/lib/python3.8/site-packages/numpy-1.16.4-py3.8-macosx-10.14-x86_64.egg/numpy/core/getlimits.py", line 100, in _register_known_types
  "/Users/nelson/.graalenv/lib/python3.8/site-packages/numpy-1.16.4-py3.8-macosx-10.14-x86_64.egg/numpy/core/getlimits.py", line 54, in __init__
  File "number.c", line 284, in array_power
  File "ufunc_object.c", line 4688, in ufunc_generic_call
  File "ufunc_object.c", line 3178, in PyUFunc_GenericFunction
  File "ufunc_type_resolution.c", line 180, in PyUFunc_DefaultTypeResolver
  File "ufunc_type_resolution.c", line 2028, in linear_search_type_resolver
  File "ufunc_type_resolution.c", line 1639, in ufunc_loop_matches
  File "convert_datatype.c", line 904, in PyArray_CanCastArrayTo
java.lang.AssertionError
madeinquant commented 3 years ago

I found that there are a lot of environment variables in ~/.bash_profile. I comment all of them and compile numpy/pandas successfully. By the way, how do I verify the settings of gcc/clang is correct? Anyway, thank you for your help.


    #export CC=/usr/local/Cellar/gcc/10.1.0/bin/gcc-10
    #export CXX=/usr/local/Cellar/gcc/10.1.0/bin/g++-10

    #export CC=/usr/bin/clang
    #export CXX=/usr/bin/clang++

    #export C_INCLUDE_PATH=/usr/local/Cellar/libiomp/20150701/include/libiomp:$C_INCLUDE_PATH
    #export CPLUS_INCLUDE_PATH=/usr/local/Cellar/libiomp/20150701/include/libiomp/:$CPLUS_INCLUDE_PATH
    #export LIBRARY_PATH=/usr/local/Cellar/libiomp/20150701/lib:$LIBRARY_PATH
    #export DYLD_LIBRARY_PATH=/usr/local/Cellar/libiomp/20150701/lib:$DYLD_LIBRARY_PATH

    #export MPICXX=mpicxx
    #export LDFLAGS="-pthread -lm"
    #export CFLAGS="-Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -fopenmp"
msimacek commented 3 years ago

I'm glad that you figured it out. You shouldn't set anything for graalpython, we ship our own LLVM toolchain (our own clang and related utilities) that should work out of the box.

@timfel @fangerer should we do some more checks for these environment variables and filter them out or emit a warning when they could be incompatible?

fangerer commented 3 years ago

Yes, we should definitively print a warning if someone uses custom compiler tools. We currently pass these env vars through to enable users to use something like ccache. We could also just ignore these env vars and add options that allow a user to override the compiler and others.

msimacek commented 1 year ago

We no longer use LLVM toolchain by default, so no need for adding any warnings, custom compilers and flags should work the same as under CPython.