Should python-dev be required to install pip

后端 未结 2 1643
梦毁少年i
梦毁少年i 2020-12-30 03:33

I find that many people have troubles installing python packages with pip because python-dev is not installed. Mainly, the error:

fatal error: Python.h: No         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 04:15

    I checked how popular PyPi packages handle missing Python.h. My first problem was to find popular PyPi packages that build a C extension, which I solved by checking zmq/pyzmq, grpcio, and python-qpid-proton, which I know are three packages doing this.

    The zmq package prints a generic catch-all error message. The grpcio package prints a specific error message which tries to be maximally helpful. The python-qpid-proton package prints the compiler error only.

    ZMQ

        build/temp.linux-x86_64-3.7/scratch/vers.c:4:10: fatal error: zmq.h: No such file or directory                                                                                                                                           
            4 | #include "zmq.h"                                                                                                                                                                                                                 
              |          ^~~~~~~                                                                                                                                                                                                                 
        compilation terminated.                                                                                                                                                                                                                  
    
        error: command 'gcc' failed with exit status 1                                                                                                                                                                                           
    
        ************************************************                                                                                                                                                                                         
        Warning: Couldn't find an acceptable libzmq on the system.                                                                                                                                                                               
    
        If you expected pyzmq to link against an installed libzmq, please check to make sure:                                                                                                                                                    
    
            * You have a C compiler installed                                                                                                                                                                                                    
            * A development version of Python is installed (including headers)
            * A development version of ZMQ >= 3.2 is installed (including headers)
            * If ZMQ is not in a default location, supply the argument --zmq=
            * If you did recently install ZMQ to a default location,
              try rebuilding the ld cache with `sudo ldconfig`
              or specify zmq's location with `--zmq=/usr/local`
    

    https://gist.github.com/jiridanek/0fcd09f27d379ae984b84f174986093d

    gRPC.io

        commands.CommandError: Diagnostics found a compilation environment issue:
    
        Could not find . This could mean the following:
          * You're on Ubuntu and haven't run `apt-get install python-dev`.
          * You're on RHEL/Fedora and haven't run `yum install python-devel` or
            `dnf install python-devel` (make sure you also have redhat-rpm-config
            installed)
          * You're on Mac OS X and the usual Python framework was somehow corrupted
            (check your environment variables or try re-installing?)
          * You're on Windows and your Python installation was somehow corrupted
            (check your environment variables or try re-installing?)
    

    https://gist.github.com/jiridanek/9bff05ae79b0eb5207821fc524acf12a

    Python Qpid Proton

    cproton_wrap.c:150:21: fatal error: Python.h: No such file or directory
          # include 
                              ^
    compilation terminated.     
    error: command 'gcc' failed with exit status 1
    

提交回复
热议问题