python - 异常 : Version mismatch: this is the 'cffi' package version 1. 13.1,

标签 python pip numba

我尝试使用 CUDA 运行代码,出现此错误,系统似乎有问题

完整代码:我知道了 CUDACast #10a - Your First CUDA Python Programno module named numbapro

import numpy as np
from timeit import default_timer as timer
from numba import vectorize

@vectorize(["float32(float32, float32)"], target='cuda')


def VectorAdd(a, b):
        return a + b

def main():
    N = 32000000

    A = np.ones(N, dtype=np.float32)
    B = np.ones(N, dtype=np.float32)
    C = np.zeros(N, dtype=np.float32)

    start = timer()
    C = VectorAdd(A, B)
    vectoradd_timer = timer() - start

    print("C[:5] = " + str(C[:5]))
    print("C[-5:] = " + str(C[-5:]))

    print("VectorAdd took %f seconds" % vectoradd_timer)

if __name__ == '__main__':
    main()

输出:

Exception: Version mismatch: this is the 'cffi' package version 1.13.1, located in '/usr/local/lib/python2.7/dist-packages/cffi/api.pyc'. When we import the top-level '_cffi_backend' extension module, we get version 1.5.2, located in '/usr/lib/python2.7/dist-packages/_cffi_backend.x86_64-linux-gnu.so'. The two versions should be equal; check your installation.



也许是这个原因:
$which pip
/usr/bin/pip

最佳答案

您必须尝试单独删除所有 cffi 软件包并安装版本 1.5.2 .

sudo pip install cffi==1.5.2

或者您可以通过更新旧版本来确保版本一致。
sudo apt-get install python-cffi

希望对你有帮助

关于python - 异常 : Version mismatch: this is the 'cffi' package version 1. 13.1,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58552666/

相关文章:

python - 获取有关在 Python 装饰器中调用代码的特定信息

python - 不透明度的 QVariantAnimation : the item appears at the end of the animation

python-3.x - 在 Ubuntu 上使用 pip 时出现无效的 IPv6 URL 错误

python-2.7 - 如何修复 pip 安装错误 : 'EnvironmentError: [Errno 42] Illegal byte sequence' ?

python - 使用 python 需求文件,您可以控制安装包依赖项的顺序吗?

python - 如何使用 ndarray 参数和/或输出定义 numba 类?

python - 在 Python 中使用多处理,导入语句的正确方法是什么?

Python 双重排序与分割字符串

python - LoweringError 是什么意思?

python Pandas : banal apply statements incredibly slow