SheffieldML / GPy

Gaussian processes framework in python
BSD 3-Clause "New" or "Revised" License
2.04k stars 562 forks source link

Install fails - linux - compile issues - numpy import_array() #692

Open ajgpitch opened 6 years ago

ajgpitch commented 6 years ago

Hello, I was unable to install on Linux. I tried pip and from source. There did not seem to be any error, just warnings relating to numpy import_array(). The console output and conda env list is copied below.

I have done a bit of searching and found a solution. I will make a PR of the proposed fix just now.

Console output

(bayesopt) agp1@imapspc0049 ~/GitHub/ajgpitch/GPy $ python setup.py develop
running develop
running egg_info
writing GPy.egg-info/PKG-INFO
writing dependency_links to GPy.egg-info/dependency_links.txt
writing requirements to GPy.egg-info/requires.txt
writing top-level names to GPy.egg-info/top_level.txt
reading manifest file 'GPy.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'README.rst'
writing manifest file 'GPy.egg-info/SOURCES.txt'
running build_ext
building 'GPy.kern.src.stationary_cython' extension
gcc -pthread -B /home/agp1/anaconda3/envs/bayesopt/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/agp1/anaconda3/envs/bayesopt/lib/python3.7/site-packages/numpy/core/include -I. -I/home/agp1/anaconda3/envs/bayesopt/include/python3.7m -c GPy/kern/src/stationary_cython.c -o build/temp.linux-x86_64-3.7/GPy/kern/src/stationary_cython.o -fopenmp -O3
In file included from /home/agp1/anaconda3/envs/bayesopt/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1823:0,
                 from /home/agp1/anaconda3/envs/bayesopt/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                 from /home/agp1/anaconda3/envs/bayesopt/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from GPy/kern/src/stationary_cython.c:242:
/home/agp1/anaconda3/envs/bayesopt/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^
GPy/kern/src/stationary_cython.c: In function ‘__Pyx_ExceptionSave’:
GPy/kern/src/stationary_cython.c:19389:19: error: ‘PyThreadState’ has no member named ‘exc_type’
     *type = tstate->exc_type;
                   ^
GPy/kern/src/stationary_cython.c:19390:20: error: ‘PyThreadState’ has no member named ‘exc_value’
     *value = tstate->exc_value;
                    ^
GPy/kern/src/stationary_cython.c:19391:17: error: ‘PyThreadState’ has no member named ‘exc_traceback’
     *tb = tstate->exc_traceback;
                 ^
GPy/kern/src/stationary_cython.c: In function ‘__Pyx_ExceptionReset’:
GPy/kern/src/stationary_cython.c:19403:22: error: ‘PyThreadState’ has no member named ‘exc_type’
     tmp_type = tstate->exc_type;
                      ^
GPy/kern/src/stationary_cython.c:19404:23: error: ‘PyThreadState’ has no member named ‘exc_value’
     tmp_value = tstate->exc_value;
                       ^
GPy/kern/src/stationary_cython.c:19405:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
     tmp_tb = tstate->exc_traceback;
                    ^
GPy/kern/src/stationary_cython.c:19406:11: error: ‘PyThreadState’ has no member named ‘exc_type’
     tstate->exc_type = type;
           ^
GPy/kern/src/stationary_cython.c:19407:11: error: ‘PyThreadState’ has no member named ‘exc_value’
     tstate->exc_value = value;
           ^
GPy/kern/src/stationary_cython.c:19408:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
     tstate->exc_traceback = tb;
           ^
GPy/kern/src/stationary_cython.c: In function ‘__Pyx_GetException’:
GPy/kern/src/stationary_cython.c:19451:22: error: ‘PyThreadState’ has no member named ‘exc_type’
     tmp_type = tstate->exc_type;
                      ^
GPy/kern/src/stationary_cython.c:19452:23: error: ‘PyThreadState’ has no member named ‘exc_value’
     tmp_value = tstate->exc_value;
                       ^
GPy/kern/src/stationary_cython.c:19453:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
     tmp_tb = tstate->exc_traceback;
                    ^
GPy/kern/src/stationary_cython.c:19454:11: error: ‘PyThreadState’ has no member named ‘exc_type’
     tstate->exc_type = local_type;
           ^
GPy/kern/src/stationary_cython.c:19455:11: error: ‘PyThreadState’ has no member named ‘exc_value’
     tstate->exc_value = local_value;
           ^
GPy/kern/src/stationary_cython.c:19456:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
     tstate->exc_traceback = local_tb;
           ^
GPy/kern/src/stationary_cython.c: In function ‘__Pyx_ExceptionSwap’:
GPy/kern/src/stationary_cython.c:19478:22: error: ‘PyThreadState’ has no member named ‘exc_type’
     tmp_type = tstate->exc_type;
                      ^
GPy/kern/src/stationary_cython.c:19479:23: error: ‘PyThreadState’ has no member named ‘exc_value’
     tmp_value = tstate->exc_value;
                       ^
GPy/kern/src/stationary_cython.c:19480:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
     tmp_tb = tstate->exc_traceback;
                    ^
GPy/kern/src/stationary_cython.c:19481:11: error: ‘PyThreadState’ has no member named ‘exc_type’
     tstate->exc_type = *type;
           ^
GPy/kern/src/stationary_cython.c:19482:11: error: ‘PyThreadState’ has no member named ‘exc_value’
     tstate->exc_value = *value;
           ^
GPy/kern/src/stationary_cython.c:19483:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
     tstate->exc_traceback = *tb;
           ^
In file included from /home/agp1/anaconda3/envs/bayesopt/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:27:0,
                 from /home/agp1/anaconda3/envs/bayesopt/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from GPy/kern/src/stationary_cython.c:242:
GPy/kern/src/stationary_cython.c: At top level:
/home/agp1/anaconda3/envs/bayesopt/lib/python3.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1463:1: warning: ‘_import_array’ defined but not used [-Wunused-function]
 _import_array(void)
 ^
error: command 'gcc' failed with exit status 1

conda env

# packages in environment at /home/agp1/anaconda3/envs/bayesopt:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.12                   py37_0  
asn1crypto                0.24.0                   py37_0  
astroid                   2.0.4                    py37_0  
babel                     2.6.0                    py37_0  
backcall                  0.1.0                    py37_0  
blas                      1.0                         mkl  
bleach                    3.0.2                    py37_0  
ca-certificates           2018.03.07                    0  
certifi                   2018.10.15               py37_0  
cffi                      1.11.5           py37he75722e_1  
chardet                   3.0.4                    py37_1  
cloudpickle               0.6.1                    py37_0  
cryptography              2.3.1            py37hc365091_0  
cycler                    0.10.0                   py37_0  
cython                    0.29             py37he6710b0_0  
dbus                      1.13.2               h714fa37_1  
decorator                 4.3.0                    py37_0  
docutils                  0.14                     py37_0  
entrypoints               0.2.3                    py37_2  
expat                     2.2.6                he6710b0_0  
fontconfig                2.13.0               h9420a91_0  
freetype                  2.9.1                h8a8886c_1  
glib                      2.56.2               hd408876_0  
gmp                       6.1.2                h6c8ec71_1  
GPy                       1.9.5                     <pip>
GPyOpt                    1.2.5                     <pip>
gst-plugins-base          1.14.0               hbbd80ab_1  
gstreamer                 1.14.0               hb453b48_1  
icu                       58.2                 h9c2bf20_1  
idna                      2.7                      py37_0  
imagesize                 1.1.0                    py37_0  
intel-openmp              2019.0                      118  
ipykernel                 5.0.0            py37h39e3cac_0  
ipython                   7.0.1            py37h39e3cac_0  
ipython_genutils          0.2.0                    py37_0  
isort                     4.3.4                    py37_0  
jedi                      0.13.1                   py37_0  
jeepney                   0.4                      py37_0  
jinja2                    2.10                     py37_0  
jpeg                      9b                   h024ee3a_2  
jsonschema                2.6.0                    py37_0  
jupyter_client            5.2.3                    py37_0  
jupyter_core              4.4.0                    py37_0  
keyring                   15.1.0                   py37_0  
kiwisolver                1.0.1            py37hf484d3e_0  
lazy-object-proxy         1.3.1            py37h14c3975_2  
libedit                   3.1.20170329         h6b74fdf_2  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 8.2.0                hdf63c60_1  
libgfortran-ng            7.3.0                hdf63c60_0  
libpng                    1.6.35               hbc83047_0  
libsodium                 1.0.16               h1bed415_0  
libstdcxx-ng              8.2.0                hdf63c60_1  
libuuid                   1.0.3                h1bed415_2  
libxcb                    1.13                 h1bed415_1  
libxml2                   2.9.8                h26e45fe_1  
markupsafe                1.0              py37h14c3975_1  
matplotlib                3.0.0            py37h5429711_0  
mccabe                    0.6.1                    py37_1  
mistune                   0.8.4            py37h7b6447c_0  
mkl                       2019.0                      118  
mkl_fft                   1.0.6            py37h7dd41cf_0  
mkl_random                1.0.1            py37h4414c95_1  
nbconvert                 5.3.1                    py37_0  
nbformat                  4.4.0                    py37_0  
ncurses                   6.1                  hf484d3e_0  
nose                      1.3.7                    py37_2  
numpy                     1.15.2           py37h1d66e8a_1  
numpy-base                1.15.2           py37h81de0dd_1  
numpydoc                  0.8.0                    py37_0  
openssl                   1.0.2p               h14c3975_0  
packaging                 18.0                     py37_0  
pandoc                    2.2.3.2                       0  
pandocfilters             1.4.2                    py37_1  
paramz                    0.9.4                     <pip>
parso                     0.3.1                    py37_0  
pcre                      8.42                 h439df22_0  
pexpect                   4.6.0                    py37_0  
pickleshare               0.7.5                    py37_0  
pip                       18.1                      <pip>
pip                       10.0.1                   py37_0  
prompt_toolkit            2.0.6                    py37_0  
psutil                    5.4.7            py37h14c3975_0  
ptyprocess                0.6.0                    py37_0  
pycodestyle               2.4.0                    py37_0  
pycparser                 2.19                     py37_0  
pyflakes                  2.0.0                    py37_0  
pygments                  2.2.0                    py37_0  
pylint                    2.1.1                    py37_0  
pyopenssl                 18.0.0                   py37_0  
pyparsing                 2.2.2                    py37_0  
pyqt                      5.9.2            py37h05f1152_2  
pysocks                   1.6.8                    py37_0  
python                    3.7.0                h6e4f718_3  
python-dateutil           2.7.3                    py37_0  
pytz                      2018.5                   py37_0  
pyzmq                     17.1.2           py37h14c3975_0  
qt                        5.9.6                h8703b6f_2  
qtawesome                 0.5.1                    py37_1  
qtconsole                 4.4.1                    py37_0  
qtpy                      1.5.1                    py37_0  
qutip                     4.3.1                     <pip>
readline                  7.0                  h7b6447c_5  
requests                  2.19.1                   py37_0  
rope                      0.11.0                   py37_0  
scipy                     1.1.0            py37hfa4b5c9_1  
secretstorage             3.1.0                    py37_0  
setuptools                40.4.3                   py37_0  
simplegeneric             0.8.1                    py37_2  
sip                       4.19.8           py37hf484d3e_0  
six                       1.11.0                   py37_1  
snowballstemmer           1.2.1                    py37_0  
sphinx                    1.8.1                    py37_0  
sphinxcontrib             1.0                      py37_1  
sphinxcontrib-websupport  1.1.0                    py37_1  
spyder                    3.3.1                    py37_1  
spyder-kernels            0.2.6                    py37_0  
sqlite                    3.25.2               h7b6447c_0  
testpath                  0.4.2                    py37_0  
tk                        8.6.8                hbc83047_0  
tornado                   5.1.1            py37h7b6447c_0  
traitlets                 4.3.2                    py37_0  
urllib3                   1.23                     py37_0  
wcwidth                   0.1.7                    py37_0  
webencodings              0.5.1                    py37_1  
wheel                     0.32.1                   py37_0  
wrapt                     1.10.11          py37h14c3975_2  
xz                        5.2.4                h14c3975_4  
zeromq                    4.2.5                hf484d3e_1  
zlib                      1.2.11               ha838bed_2  
ajgpitch commented 6 years ago

Actually I found that what actually fixed the the problem was the re cythonize of the source files. Works even without the fix in #693

ajgpitch commented 6 years ago

This would be resolved by #695 and #696 and then using

python setup.py build_ext --force
python setup.py install

to force rebuild of the *.c files and then install

ajgpitch commented 5 years ago

I'm still getting this error installing from source (latest devel branch) on Linux Mint 19 with Python 3.7

At top level:
/home/agp1/.conda/envs/bayesopt/lib/python3.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1463:1: warning: ‘_import_array’ defined but not used [-Wunused-function]
 _import_array(void)
 ^~~~~~~~~~~~~
error: command 'gcc' failed with exit status 1
lionfish0 commented 5 years ago

I don't know if this is the same problem but make sure the necessary libraries are installed and up to date with... (copying from other issue):...

I'm not sure which of these are necessary, sorry, but some combination of the below will probably fix this (on AWS Ubuntu 18.04 anyway)

sudo apt-get install python3-dev
sudo apt-get update
sudo apt-get install build-essential

or maybe: conda update anaconda

(please let us know if that solves your problems)