Skip to content Skip to sidebar Skip to footer

Pynacl Building Problems

So I'm trying to download discord's API into my venv with pip but it's failing to build PyNaCl. It says that the error is that the 'make' utility is missing from PATH but I just ad

Solution 1:

'make' utility is missing from PATH


The cause of this error

This error is caused by a BUG in setup.py of PyNacl source code.

However, even if you fix it, you will encounter more problem since that source code does not intend for building on windows.

If you just want to install PyNacl, see the next section.

If you want to know the detail of that BUG, see the last section.


Installing PyNacl

After Sep 14, 2020, pynacl has abi3 pre-built wheel, so pip install pynacl will automatically download and install it. You don't need to build pynacl by yourself.

  • You can also manually download PyNaCl-1.4.0-cp35-abi3-win_amd64.whl and pip install PyNaCl-1.4.0-cp35-abi3-win_amd64.whl (in download dir).

  • If you get an error, you can use pip install -U pip to upgrade pip and try again.

  • If you still get an error, you can use pip debug -v to check compatible tags:

  • If the compatible tags have the "win_amd64" postfix, there should be a "cp35-abi3-win_amd64" tag, and pip install should succeed.

  • If the compatible tags have the "mingw_x86_64" or "mingw_x86_64_ucrt" postfix, you must build pynacl by yourself (or install win_amd64 python).

pynacl lists libsodium as a dependency. Fortunately, you don't need to build libsodium (which needs make, causing the error you encountered).

Then pip will use PEP517 to build and install pynacl for you with pre-built libsodium. Or, you can build by yourself (download the source code from pypi, and in the source code directory):

SODIUM_INSTALL=system python setup.py bdist_wheel

With cmd or powershell, you cannot set environment variable in the bash style. You can use following instead:

$env:SODIUM_INSTALL="system";pip install pynacl

Details of the bug

The error is raised here:

if not which("make"):
    raise Exception("ERROR: The 'make' utility is missing from PATH")

And the function which is implemented with a BUG:

def which(name, flags=os.X_OK):  # Taken from twisted
    result = []
    exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
    path = os.environ.get('PATH', None)
    ifpath is None:
        return []
    for p inos.environ.get('PATH', '').split(os.pathsep):
        p = os.path.join(p, name)
        ifos.access(p, flags):
            result.append(p)
        for e in exts:
            pext = p + e
            ifos.access(pext, flags):
                result.append(pext)
    return result

In Python3, filter returns an iterator, not a list (python2's filter returns a list). Thus, the "exts" will be "exhausted" in the first iteration. You can replace filter(...) with list(filter(...)) to fix it.

Post a Comment for "Pynacl Building Problems"