pip install pyaxttr error

[root@data1 /]# pip3 install pyxattr
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pyxattr
  Using cached https://files.pythonhosted.org/packages/cf/b1/7ed931d98b5a91a59b69fcc2860e5b720a22ed1ddb85268415181c9b0986/pyxattr-0.7.1.tar.gz
Installing collected packages: pyxattr
  Running setup.py install for pyxattr ... error
    Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3t4hxmm1/pyxattr/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-ez3zmi5b-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'xattr' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -D_XATTR_VERSION="0.7.1" -D_XATTR_AUTHOR="Iustin Pop" -D_XATTR_EMAIL="[email protected]" -I/usr/include/python3.6m -c xattr.c -o build/temp.linux-x86_64-3.6/xattr.o -Wall -Werror -Wsign-compare
    xattr.c:25:10: fatal error: Python.h: No such file or directory
     #include <Python.h>
              ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3t4hxmm1/pyxattr/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-ez3zmi5b-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-3t4hxmm1/pyxattr/

You can see that the Python.h file is missing, enter the /lib/pythonx.x directory to see if the file is missing

[root@data1 /]# cd /usr/include/python3.6m/
[root@data1 python3.6m]# ls
pyconfig-64.h

If not, install python-devel (Ubuntu should install python-dev)

[root@data1 /]# yum search python | grep devel
Last metadata expiration check: 0:18:02 ago on Mon 06 Jul 2020 02:23:55 AM UTC
....
python36-devel.x86_64 : Libraries and header files needed for Python development
python38-devel.x86_64 : Libraries and header files needed for Python development
...
[root@data1 /]# yum install python36-devel.x86_64

Just install it again

[root@data1 /]# pip3 install pyxattr
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pyxattr
  Using cached https://files.pythonhosted.org/packages/cf/b1/7ed931d98b5a91a59b69fcc2860e5b720a22ed1ddb85268415181c9b0986/pyxattr-0.7.1.tar.gz
Installing collected packages: pyxattr
  Running setup.py install for pyxattr ... done
Successfully installed pyxattr-0.7.1

Guess you like

Origin blog.csdn.net/JosephThatwho/article/details/107152187