How to resolve, Import "pqcrypto" could not be resolved?


I am trying to use the pqcrypto library but can not resolve the issue:

Import "pqcrypto" could not be resolved Pylance (reportMissingImports)

I am using python 3.10.6 on a ubuntu 22.4 virtual machine (virtual box). Pip version 23.0.1.

Initially I could not pip install this library and constantly failed to build wheel during install.

× Building wheel for pqcrypto (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [49 lines of output]
      A file already exists. Using it.
      Traceback (most recent call last):
        File "/tmp/pip-install-8f35n23e/pqcrypto_15372684f61345f19dab295f64d05a2a/", line 31, in <module>
        File "/usr/lib/python3/dist-packages/setuptools/", line 153, in setup
          return distutils.core.setup(**attrs)
        File "/usr/lib/python3.10/distutils/", line 108, in setup
          _setup_distribution = dist = klass(attrs)
        File "/usr/lib/python3/dist-packages/setuptools/", line 459, in __init__
        File "/usr/lib/python3.10/distutils/", line 292, in __init__
        File "/usr/lib/python3/dist-packages/setuptools/", line 837, in finalize_options
        File "/usr/lib/python3/dist-packages/setuptools/", line 858, in _finalize_setup_keywords
          ep.load()(self,, value)
        File "/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/cffi/", line 219, in cffi_modules
          add_cffi_module(dist, cffi_module)
        File "/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/cffi/", line 49, in add_cffi_module
          execfile(build_file_name, mod_vars)
        File "/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/cffi/", line 25, in execfile
          exec(code, glob, glob)
        File "", line 80, in <module>
          algorithm_ffi = create_algorithm_ffi(algorithm, **kwargs)
        File "", line 60, in create_algorithm_ffi
          ffi = FFI()
        File "/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/cffi/", line 54, in __init__
          raise Exception("Version mismatch: this is the 'cffi' package version %s, located in %r.  When we import the top-level '_cffi_backend' extension module, we get version %s, located in %r.  The two versions should be equal; check your installation." % (
      Exception: Version mismatch: this is the 'cffi' package version 1.15.1, located in '/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/cffi/'.  When we import the top-level '_cffi_backend' extension module, we get version 1.15.0, located in '/usr/lib/python3/dist-packages/'.  The two versions should be equal; check your installation.
      Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/", line 363, in <module>
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/", line 261, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/", line 56, in build_wheel
          return WheelBuilder.make_in(
        File "/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/", line 85, in make_in

        File "/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/", line 118, in build
        File "/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/", line 179, in _build
        File "/tmp/pip-build-env-ifogc2y8/overlay/local/lib/python3.10/dist-packages/poetry/core/masonry/builders/", line 217, in _run_build_command
        File "/usr/lib/python3.10/", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/usr/bin/python3', '/tmp/pip-install-8f35n23e/pqcrypto_15372684f61345f19dab295f64d05a2a/', 'build', '-b', '/tmp/pip-install-8f35n23e/pqcrypto_15372684f61345f19dab295f64d05a2a/build']' returned non-zero exit status 1.
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pqcrypto
Failed to build pqcrypto
ERROR: Could not build wheels for pqcrypto, which is required to install pyproject.toml-based projects

To remedy this I downloaded the tar itself and installed with this command:

sudo python install

It seems to have installed but not satisfied the error. Subsequent pip install commands produce this:

$ pip install pqcrypto
Requirement already satisfied: pqcrypto in /home/mack/Desktop/RSAvsCK/venv/lib/python3.10/site-packages/pqcrypto-0.1.3-py3.10-linux-x86_64.egg (0.1.3)
Requirement already satisfied: cffi<2.0.0,>=1.14.2 in ./.eggs/cffi-1.15.1-py3.10-linux-x86_64.egg (from pqcrypto) (1.15.1)
Requirement already satisfied: pycparser in ./.eggs/pycparser-2.21-py3.10.egg (from cffi<2.0.0,>=1.14.2->pqcrypto) (2.21)

And running pip show pqcrypto produces this:

$ pip show pqcrypto
Name: pqcrypto
Version: 0.1.3
Summary: Post-quantum cryptography for Python.
Author: Phil Demetriou
Author-email: [email protected]
Location: /home/mack/Desktop/RSAvsCK/venv/lib/python3.10/site-packages/pqcrypto-0.1.3-py3.10-linux-x86_64.egg
Requires: cffi

I have tried this in and without a virtual environment, but that’s not to say I did not make a mistake in either process. Thanks much.

Asked By: Mack Osborne



Installation of pqcrypto is not as simple as a pip install command despite it saying so in pypi.

See the official libpqcrypto website here:

Installation commands are as follows, note you must be the root user so sudo is omitted here.

gcc and other compiler tools:

apt install build-essential`

OpenSSL header files:

apt install libssl-dev`

GMP header files:

apt install libgmp-dev

In a root terminal, create a libpqcrypto user:

    adduser --disabled-password --gecos libpqcrypto libpqcrypto

Run a shell as that user:

    su - libpqcrypto

As that user, download and unpack the latest version of libpqcrypto:

    wget -m
    wget -m$version.tar.gz
    tar -xzf$version.tar.gz
    cd libpqcrypto-$version
    ln -s $HOME link-build
    ln -s $HOME link-install

Compile, test, and install (this takes time):


Exit the user shell:

Answered By: Mack Osborne