Pycrypto on Alpine

This is just a quick post for weary travelers out there trying to find answers.

On Alpine Linux, Pycrypto may not compile correctly. This is because Alpine uses the musl C library as opposed to the C standard library. When trying to compile, you may end up with something like this:

checking for gcc... gcc  
checking whether the C compiler works... no  
configure: error: in `/tmp/pycrypto-2.6.1':  
configure: error: C compiler cannot create executables  
See `config.log' for more details  

Or, if building from pip:

    running build_configure
    checking for gcc... gcc
    checking whether the C compiler works... no
    configure: error: in `/tmp/pip-build-_wxuipnm/pycrypto':
    configure: error: C compiler cannot create executables
    See `config.log' for more details
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-_wxuipnm/pycrypto/setup.py", line 456, in <module>
        core.setup(**kw)
      File "/usr/local/lib/python3.5/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/lib/python3.5/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.5/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/local/lib/python3.5/distutils/command/install.py", line 539, in run
        self.run_command('build')
      File "/usr/local/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.5/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/local/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-_wxuipnm/pycrypto/setup.py", line 251, in run
        self.run_command(cmd_name)
      File "/usr/local/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-_wxuipnm/pycrypto/setup.py", line 278, in run
        raise RuntimeError("autoconf error")
    RuntimeError: autoconf error

Simple solution: Ensure all your dependencies are correctly installed!

apk add openssl libc-dev python-dev gcc  

UPDATE (9/9/16): Added a couple overlooked dependencies thanks to a kind commentator.

Sean Johnson

Software developer, music enthusiast, college student, and cat lover. Currently enthralled by the world of networking, security, and cloud technology.

San Antonio, TX https://blog.maio.me

Subscribe to Land of Weird Things

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!