本文介绍了Ubuntu 20.04 升级,Python 缺少 libffi.so.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的操作系统升级到了 Ubuntu 20.04 LTS.

I recently upgraded my OS to Ubuntu 20.04 LTS.

现在,当我尝试在 Python 中导入像 Numpy 这样的库时,出现以下错误:

Now when I try to import a library like Numpy in Python, I get the following error:

ImportError: libffi.so.6: cannot open shared object file: No such file or directory

我尝试安装 libffi 包,但 apt 找不到它:

I tried installing the libffi package, but apt can't locate it :

sudo apt-get install libffi
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libffi

推荐答案

我好像修复了它.我可能是错的,但这是我认为发生的事情:

It seems like I fixed it. I could be wrong, but here is what I think happened:

  1. Ubuntu 20.04 将 libffi6 升级为 libffi7
  2. Python 仍在寻找 libffi6

我做了什么来修复它:

在您的系统中找到 libffi.so.7

$ find /usr/lib -name "libffi.so*"

创建一个名为 libffi.so.6 的 simlink,指向 libffi.so.7:

Create a simlink named libffi.so.6 that points to libffi.so.7:

sudo ln -s /usr/path/to/libffi.so.7 /usr/lib/path/to/libffi.so.6

更新:

正如许多用户所指出的,此修复程序可能会产生意想不到的后果.更好的方法是按照@amichaud 的解释重新安装 python.如果您不使用 pyenv/virtualenv/etc,这应该用作最后的手段,在这种情况下,删除 python 也会导致许多依赖项也被删除.

As noted by many users, this fix could have unintended consequences. The better way to do it is to reinstall python as @amichaud explained. This should be used as a last resort IF you're not using pyenv/virtualenv/etc in which case removing python will cause a lot of dependencies to be removed as well.

这篇关于Ubuntu 20.04 升级,Python 缺少 libffi.so.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-20 10:39