david-cortes / costsensitive

(Python, R) Cost-sensitive multiclass classification (Weighted-All-Pairs, Filter-Tree & others)
BSD 2-Clause "Simplified" License
47 stars 19 forks source link

Installation problem #5

Open npfernandeztheillet opened 5 years ago

npfernandeztheillet commented 5 years ago

Hi David, how are you? I hope you are well.

I tried to install the library but I got this error:

Collecting costsensitive Using cached https://files.pythonhosted.org/packages/08/01/9d8a0c5c07db31ba8b17ccc0506db0d899ef342a9a57fa937b9b8b01c066/costsensitive-0.1.2.10.tar.gz Requirement already up-to-date: cython in /home/notebooks/venv/lib/python3.6/site-packages (from costsensitive) Requirement already up-to-date: joblib>=0.13 in /home/notebooks/venv/lib/python3.6/site-packages (from costsensitive) Collecting numpy (from costsensitive) Downloading https://files.pythonhosted.org/packages/19/b9/bda9781f0a74b90ebd2e046fde1196182900bd4a8e1ea503d3ffebc50e7c/numpy-1.17.0-cp36-cp36m-manylinux1_x86_64.whl (20.4MB) 100% |████████████████████████████████| 20.4MB 96kB/s s eta 0:00:01 Requirement already up-to-date: scipy in /home/notebooks/venv/lib/python3.6/site-packages (from costsensitive) Building wheels for collected packages: costsensitive Running setup.py bdist_wheel for costsensitive ... error Complete output from command /home/notebooks/venv/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-652t1zkx/costsensitive/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 /tmp/tmp6frkpu00pip-wheel- --python-tag cp36: usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: -c --help [cmd1 cmd2 ...] or: -c --help-commands or: -c cmd --help

error: invalid command 'bdist_wheel'


Failed building wheel for costsensitive Running setup.py clean for costsensitive Failed to build costsensitive Installing collected packages: numpy, costsensitive Found existing installation: numpy 1.16.4 Uninstalling numpy-1.16.4: Successfully uninstalled numpy-1.16.4 Running setup.py install for costsensitive ... error Complete output from command /home/notebooks/venv/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-652t1zkx/costsensitive/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-08s1e5tx-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/notebooks/venv/include/site/python3.6/costsensitive: running install running build running build_py creating build creating build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/costsensitive copying costsensitive/init.py -> build/lib.linux-x86_64-3.6/costsensitive running build_ext cythoning costsensitive/vwrapper.pyx to costsensitive/vwrapper.c /home/notebooks/venv/lib/python3.6/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-build-652t1zkx/costsensitive/costsensitive/vwrapper.pyx tree = Parsing.p_module(s, pxd, full_module_name) building 'costsensitive._vwrapper' extension creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/costsensitive x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/notebooks/venv/lib/python3.6/site-packages/numpy/core/include -I/home/notebooks/venv/include -I/usr/include/python3.6m -c costsensitive/vwrapper.c -o build/temp.linux-x86_64-3.6/costsensitive/vwrapper.o -O2 -march=native -std=c99 -fopenmp costsensitive/vwrapper.c:4:10: fatal error: Python.h: No such file or directory

include "Python.h"

          ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/home/notebooks/venv/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-652t1zkx/costsensitive/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-08s1e5tx-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/notebooks/venv/include/site/python3.6/costsensitive" failed with error code 1 in /tmp/pip-build-652t1zkx/costsensitive/

david-cortes commented 5 years ago

That’s a weird error.

Also, if you're running this in a virtual environment, did you install basic packages like setuptools or wheel?

npfernandeztheillet commented 5 years ago

Yes, Yes, and Yes. Also I tried to install in a windows computer, locally and I got this error (I have alreadey install Vs build tools):

n32.whl Building wheels for collected packages: costsensitive Building wheel for costsensitive (PEP 517) ... error ERROR: Command errored out with exit status 1: command: 'c:\users\appdata\local\programs\python\python37-32\python.exe' 'c:\users\appdata\local\programs\python\python37-32\lib\site-packages\pip_vendor\pep517_in_process.py' build_wheel 'C:\Users\AppData\Local\Temp\tmppyx11qmn' cwd: C:\Users\AppData\Local\Temp\pip-install-b1xgqch8\costsensitive Complete output (13 lines): running bdist_wheel running build running build_py creating build creating build\lib.win32-3.7 creating build\lib.win32-3.7\costsensitive copying costsensitive__init__.py -> build\lib.win32-3.7\costsensitive running build_ext cythoning costsensitive/vwrapper.pyx to costsensitive\vwrapper.c building 'costsensitive._vwrapper' extension C:\Users\AppData\Local\Temp\pip-build-env-erkaimxz\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\AppData\Local\Temp\pip-install-b1xgqch8\costsensitive\costsensitive\vwrapper.pyx tree = Parsing.p_module(s, pxd, full_module_name) error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

ERROR: Failed building wheel for costsensitive Running setup.py clean for costsensitive Failed to build costsensitive ERROR: Could not build wheels for costsensitive which use PEP 517 and cannot be installed directly

david-cortes commented 5 years ago

Well, the issue is that for some reason the compiler cannot find Python’s C headers. It’s not really related to this package as you’ll experience the same error if e.g. you try to run MCMC samplers from pymc3 that compile on-the-fly.

For MSVC by the way you specifically need to install the msvc140 tools, which is not selected by default (nowadays getting an MSVC or MSVC build-tools installation to work properly with Python is an odyssey, and if you don’t set it as default you’ll still need to compile with python setup.py install --compiler=msvc).

The solutions I see are:

david-cortes commented 4 years ago

I've now run into this issue when using linux with a python install from system repositories.

The solution is to install system packages named like libpython and python-dev or python-devel, or to stick to anaconda.