wmayner / pyemd

Fast EMD for Python: a wrapper for Pele and Werman's C++ implementation of the Earth Mover's Distance metric
MIT License
479 stars 62 forks source link

Error while installing pyemd on Ubuntu 20.04 #55

Closed mr-py-007 closed 3 years ago

mr-py-007 commented 3 years ago

I am using pipenv with python 3.9 Here's the error I get

Error:  An error occurred while installing pyemd!
  ERROR: Command errored out with exit status 1:
   command: /home/perseus/.local/share/virtualenvs/similarity-_ln239NJ/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h88kc0oe/pyemd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h88kc0oe/pyemd/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/pip-wheel-ilv1c_c6
       cwd: /tmp/pip-install-h88kc0oe/pyemd/
  Complete output (20 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.9
  creating build/lib.linux-x86_64-3.9/pyemd
  copying pyemd/__about__.py -> build/lib.linux-x86_64-3.9/pyemd
  copying pyemd/__init__.py -> build/lib.linux-x86_64-3.9/pyemd
  warning: build_py: byte-compiling is disabled, skipping.

  running build_ext
  building 'pyemd.emd' extension
  creating build/temp.linux-x86_64-3.9
  creating build/temp.linux-x86_64-3.9/pyemd
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/perseus/.local/share/virtualenvs/similarity-_ln239NJ/include -I/usr/include/python3.9 -I/home/perseus/.local/share/virtualenvs/similarity-_ln239NJ/lib/python3.9/site-packages/numpy/core/include -c pyemd/emd.cpp -o build/temp.linux-x86_64-3.9/pyemd/emd.o
  pyemd/emd.cpp:23:10: fatal error: Python.h: No such file or directory
     23 | #include "Python.h"
        |          ^~~~~~~~~~
  compilation terminated.
  error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for pyemd
    ERROR: Command errored out with exit status 1:
     command: /home/perseus/.local/share/virtualenvs/similarity-_ln239NJ/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h88kc0oe/pyemd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h88kc0oe/pyemd/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-record-xe7zj_p1/install-record.txt --single-version-externally-managed --compile --install-headers /home/perseus/.local/share/virtualenvs/similarity-_ln239NJ/include/site/python3.9/pyemd
         cwd: /tmp/pip-install-h88kc0oe/pyemd/
    Complete output (20 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.9
    creating build/lib.linux-x86_64-3.9/pyemd
    copying pyemd/__about__.py -> build/lib.linux-x86_64-3.9/pyemd
    copying pyemd/__init__.py -> build/lib.linux-x86_64-3.9/pyemd
    warning: build_py: byte-compiling is disabled, skipping.

    running build_ext
    building 'pyemd.emd' extension
    creating build/temp.linux-x86_64-3.9
    creating build/temp.linux-x86_64-3.9/pyemd
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/perseus/.local/share/virtualenvs/similarity-_ln239NJ/include -I/usr/include/python3.9 -I/home/perseus/.local/share/virtualenvs/similarity-_ln239NJ/lib/python3.9/site-packages/numpy/core/include -c pyemd/emd.cpp -o build/temp.linux-x86_64-3.9/pyemd/emd.o
    pyemd/emd.cpp:23:10: fatal error: Python.h: No such file or directory
       23 | #include "Python.h"
          |          ^~~~~~~~~~
    compilation terminated.
    error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/perseus/.local/share/virtualenvs/similarity-_ln239NJ/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h88kc0oe/pyemd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h88kc0oe/pyemd/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-record-xe7zj_p1/install-record.txt --single-version-externally-managed --compile --install-headers /home/perseus/.local/share/virtualenvs/similarity-_ln239NJ/include/site/python3.9/pyemd Check the logs for full command output.
mr-py-007 commented 3 years ago

@wmayner Do you have any idea?

mr-py-007 commented 3 years ago

I resolved the issue with this command.

sudo apt install libpython3.9-dev