xtensor-stack / xtensor-python

Python bindings for xtensor
BSD 3-Clause "New" or "Revised" License
347 stars 58 forks source link

example 2 has ImportError: undefined symbol xtensor_python_ARRAY_API #136

Closed Roger-luo closed 6 years ago

Roger-luo commented 6 years ago

Hi guys, I tried the example 2. But I got this ImportError. It seems that xtensor_python_ARRAY_API is not defined. I tried grep this in both xtensor and xtensor-python but I cannot find its definition.

It is used here in pycontainer.hpp

#define PY_ARRAY_UNIQUE_SYMBOL xtensor_python_ARRAY_API
SylvainCorlay commented 6 years ago

Can you please provide more details about this?

(Version of Python, Numpy, OS, more comprehensive error message?)

Roger-luo commented 6 years ago

This is the version. I did a little search, it seems that the macro PY_ARRAY_UNIQUE_SYMBOL will be defined by numpy? But I don't know why I have this error.

Python Version: Python 3.6.2 Numpy Version: 1.13.1

uname -a
4.13.0-26-generic #29~16.04.2-Ubuntu SMP Tue Jan 9 22:00:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
JohanMabille commented 6 years ago

According to this, it seems that we forgot to define FORCE_IMPORT_ARRAY and to call xt::import_numpy(); in the module definition, as it is done in the first example.

@Roger-luo can you confirm that the first example works for you? If so, can you define the FORCE_IMPORT_ARRAY symbol and call xt::import_numpy(); in the module definition of the example 2, like it is done in example 1? This should fix the problem.

Roger-luo commented 6 years ago

@JohanMabille Thanks, it works now!

SylvainCorlay commented 6 years ago

@JohanMabille qre you changing the readme example?

JohanMabille commented 6 years ago

@SylvainCorlay Yep I make a PR