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

Installation problem #5

Open
npfernandeztheillet opened this issue Aug 5, 2019 · 4 comments
Open

Installation problem #5

npfernandeztheillet opened this issue Aug 5, 2019 · 4 comments

Comments

@npfernandeztheillet
Copy link

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
Copy link
Owner

david-cortes commented Aug 5, 2019

That’s a weird error.

  • Do you have libpython installed? (conda install libpython if you use anaconda)
  • Do you have the Python executable/binary folder path in a global environment variable called PATH?
  • Do you have different parallel Python installations? Are you trying to use a root-Python install while running Python as a user?

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

@npfernandeztheillet
Copy link
Author

npfernandeztheillet commented Aug 8, 2019

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
Copy link
Owner

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:

  • Install an older pure-Python version of this package (pip install costsensitive=0.1.1).
  • Edit the setup.py file and add the path to those headers as option -I. I’m not sure if it would require additional libraries passed to -l: though.
  • Make sure that the default python that is called when you call python in the console has its own separate libpython.
  • Use conda, explicitly activate the python environment in which you want it (source activate <env. name> in linux, same without the source in windows), install libpython in that specific environment, and try again.

@david-cortes
Copy link
Owner

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.

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

No branches or pull requests

2 participants