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

Unable to install tslearn on MacOS due to Numpy headers #196

Closed
dfontenot opened this issue Mar 10, 2020 · 10 comments
Closed

Unable to install tslearn on MacOS due to Numpy headers #196

dfontenot opened this issue Mar 10, 2020 · 10 comments
Labels

Comments

@dfontenot
Copy link

Describe the bug
pip3 install tslearn fails with the following error:

Building wheels for collected packages: tslearn
  Building wheel for tslearn (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-install-qc_jggl7/tslearn/setup.py'"'"'; __file__='"'"'/private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-install-qc_jggl7/tslearn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-wheel-9sqz_lji --python-tag cp37
       cwd: /private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-install-qc_jggl7/tslearn/
  Complete output (46 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.12-x86_64-3.7
  creating build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/__init__.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/barycenters.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/bases.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/clustering.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/datasets.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/deprecated.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/generators.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/hdftools.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/metrics.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/neighbors.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/piecewise.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/preprocessing.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/shapelets.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/svm.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  copying tslearn/utils.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
  creating build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/__init__.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/sklearn_patches.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_barycenters.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_clustering.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_estimators.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_metrics.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_neighbors.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_piecewise.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_serialize_models.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_shapelets.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_utils.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  copying tslearn/tests/test_variablelength.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
  creating build/lib.macosx-10.12-x86_64-3.7/tslearn/.cached_datasets
  copying tslearn/.cached_datasets/Trace.npz -> build/lib.macosx-10.12-x86_64-3.7/tslearn/.cached_datasets
  running build_ext
  building 'tslearn.cycc' extension
  creating build/temp.macosx-10.12-x86_64-3.7
  creating build/temp.macosx-10.12-x86_64-3.7/tslearn
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c tslearn/cycc.c -o build/temp.macosx-10.12-x86_64-3.7/tslearn/cycc.o
  tslearn/cycc.c:611:10: fatal error: 'numpy/arrayobject.h' file not found
  #include "numpy/arrayobject.h"
           ^~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  error: command 'clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for tslearn
  Running setup.py clean for tslearn
Failed to build tslearn
Installing collected packages: tslearn
    Running setup.py install for tslearn ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-install-qc_jggl7/tslearn/setup.py'"'"'; __file__='"'"'/private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-install-qc_jggl7/tslearn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-record-s2w_imf2/install-record.txt --single-version-externally-managed --compile
         cwd: /private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-install-qc_jggl7/tslearn/
    Complete output (46 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.12-x86_64-3.7
    creating build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/__init__.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/barycenters.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/bases.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/clustering.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/datasets.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/deprecated.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/generators.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/hdftools.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/metrics.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/neighbors.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/piecewise.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/preprocessing.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/shapelets.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/svm.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    copying tslearn/utils.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn
    creating build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/__init__.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/sklearn_patches.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_barycenters.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_clustering.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_estimators.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_metrics.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_neighbors.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_piecewise.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_serialize_models.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_shapelets.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_utils.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_variablelength.py -> build/lib.macosx-10.12-x86_64-3.7/tslearn/tests
    creating build/lib.macosx-10.12-x86_64-3.7/tslearn/.cached_datasets
    copying tslearn/.cached_datasets/Trace.npz -> build/lib.macosx-10.12-x86_64-3.7/tslearn/.cached_datasets
    running build_ext
    building 'tslearn.cycc' extension
    creating build/temp.macosx-10.12-x86_64-3.7
    creating build/temp.macosx-10.12-x86_64-3.7/tslearn
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c tslearn/cycc.c -o build/temp.macosx-10.12-x86_64-3.7/tslearn/cycc.o
    tslearn/cycc.c:611:10: fatal error: 'numpy/arrayobject.h' file not found
    #include "numpy/arrayobject.h"
             ^~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-install-qc_jggl7/tslearn/setup.py'"'"'; __file__='"'"'/private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-install-qc_jggl7/tslearn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/fl/5t7gh9md4jn83nrmhcph3r9m0000gn/T/pip-record-s2w_imf2/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

To Reproduce
Python version: 3.7.6, pip version 19.3.1. I have installed cython as well as numpy via pip.

Expected behavior
tslearn to install

Environment (please complete the following information):

  • OS: MacOS 10.12.6
  • tslearn version 0.3.0

Additional context

>>> np.get_include()
'/usr/local/lib/python3.7/site-packages/numpy/core/include'
@dfontenot dfontenot added the bug label Mar 10, 2020
@johannfaouzi
Copy link
Contributor

Looking at this issue from hmmlearn, could you try the solution that they proposed?

export CFLAGS="-I /usr/local/lib/python3.7/site-packages/numpy/core/include $CFLAGS"

@rtavenar
Copy link
Member

@dfontenot : could you try @johannfaouzi 's trick and tell us if it works? If so, I could implement the solution suggested there as a fix.

@dfontenot
Copy link
Author

@rtavenar I believe that worked. At the end of pip3 install tslearn, after having exported that CFLAGS var:

ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/LICENSE'
Consider using the `--user` option or check the permissions.

A subsequent pip3 install -user tslearn stated the tslearn was already installed, and I could import tslearn in python3.

@mustafadgr
Copy link

mustafadgr commented Apr 13, 2020

i also have similar one:

 tslearn/cycc.c:613:10: fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1

none of the proposed methods worked for me. i tried to include these paths both to my environment as well as global path. couldn't install!!!! neither globally nor in local env.
also in setup.py np.get_include() is already present. so i don't think this method would help anyway.

@rtavenar
Copy link
Member

Hi @mustafadgr

Could you provide the same information @dfontenot did in his original post (os, python version, full error trace) so that we can try to figure out what is happening ?

@mustafadgr
Copy link

Collecting tslearn
  Downloading tslearn-0.3.1.tar.gz (548 kB)
     |████████████████████████████████| 548 kB 412 kB/s 
Requirement already satisfied: numpy in ./project_env/lib/python3.7/site-packages (from tslearn) (1.18.1)
Requirement already satisfied: scipy in ./project_env/lib/python3.7/site-packages (from tslearn) (1.4.1)
Requirement already satisfied: scikit-learn in ./project_env/lib/python3.7/site-packages (from tslearn) (0.22.2.post1)
Requirement already satisfied: Cython in ./project_env/lib/python3.7/site-packages (from tslearn) (0.29.16)
Requirement already satisfied: numba in ./project_env/lib/python3.7/site-packages (from tslearn) (0.48.0)
Requirement already satisfied: joblib in ./project_env/lib/python3.7/site-packages (from tslearn) (0.14.1)
Requirement already satisfied: setuptools in ./project_env/lib/python3.7/site-packages (from numba->tslearn) (41.2.0)
Requirement already satisfied: llvmlite<0.32.0,>=0.31.0dev0 in ./project_env/lib/python3.7/site-packages (from numba->tslearn) (0.31.0)
Installing collected packages: tslearn
    Running setup.py install for tslearn ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/mustafadoeger/491/python/project_env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-0c6eopd_/tslearn/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-0c6eopd_/tslearn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-og9816i3/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mustafadoeger/491/python/project_env/include/site/python3.7/tslearn
         cwd: /private/tmp/pip-install-0c6eopd_/tslearn/
    Complete output (47 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.15-x86_64-3.7
    creating build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/metrics.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/barycenters.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/clustering.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/hdftools.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/neighbors.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/deprecated.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/datasets.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/shapelets.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/generators.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/utils.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/preprocessing.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/piecewise.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/svm.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    copying tslearn/bases.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn
    creating build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_utils.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_estimators.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_metrics.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_barycenters.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_piecewise.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_variablelength.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_svm.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_serialize_models.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/sklearn_patches.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_shapelets.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_neighbors.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    copying tslearn/tests/test_clustering.py -> build/lib.macosx-10.15-x86_64-3.7/tslearn/tests
    creating build/lib.macosx-10.15-x86_64-3.7/tslearn/.cached_datasets
    copying tslearn/.cached_datasets/Trace.npz -> build/lib.macosx-10.15-x86_64-3.7/tslearn/.cached_datasets
    running build_ext
    building 'tslearn.cycc' extension
    creating build/temp.macosx-10.15-x86_64-3.7
    creating build/temp.macosx-10.15-x86_64-3.7/tslearn
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/Users/mustafadoeger/491/python/project_env/include -I/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c tslearn/cycc.c -o build/temp.macosx-10.15-x86_64-3.7/tslearn/cycc.o
    tslearn/cycc.c:613:10: fatal error: 'numpy/arrayobject.h' file not found
    #include "numpy/arrayobject.h"
             ^~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/mustafadoeger/491/python/project_env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-0c6eopd_/tslearn/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-0c6eopd_/tslearn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-og9816i3/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mustafadoeger/491/python/project_env/include/site/python3.7/tslearn Check the logs for full command output.

macos version: 10.15.4
python version: 3.7.6
tslearn 0.3.1

numpy.include()
'/Users/mustafadoeger/491/python/project_env/lib/python3.7/site-packages/numpy/core/include'

ps: this is virtual env, but as i said same error pops up in global environment

@johannfaouzi
Copy link
Contributor

Another related issue from another Python package: andersbll/cudarray#25

Could you try the proposed solutions there please? You may also have less trouble installing tslearn using conda (if you use conda of course).

@mustafadgr
Copy link

i don't use conda. i already saw this thread and tried them.
when i try to change
ext_modules=cythonize("tslearn/*.pyx", include_path=[numpy.get_include()]),
to:
ext_modules=cythonize("tslearn/*.pyx", include_dirs=[numpy.get_include()]),
i get an error saying remove include_dirs.
meanwhile when i try to change include_dirs in line 24 in setup.py, to include_pat i get numpy header error.

@johannfaouzi
Copy link
Contributor

According to this issue on Cython project, include_path doesn't do anything.

Looking at the documentation of Cython, and more specifically to the cythonize function, you can use the aliases parameter if you want to use include_dirs in cythonize. I really don't much about Cython, so I don't know if this can be useful or not.

Another proposed solution in the issue is to give an Extension object to the cynthonize function. It would like this I guess:

from setuptools import setup, Extension
from Cython.Build import cythonize

setup(
    ...,
    ext_modules=cythonize(Extension("tslearn", sources=["tslearn/*.pyx"], include_dirs=[numpyp.get_include()])),
    ...
)

So you would have to change line 1 to import Extension and line 31 to use an Extension inside cythonize.

I hope that it helps you a bit.

@mustafadgr
Copy link

it worked great!!! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants