Ubuntu 20.04 upgrade, Python missing libffi.so.6

后端 未结 6 1534
暗喜
暗喜 2021-02-06 20:59

I recently upgraded my OS to Ubuntu 20.04 LTS.

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

ImportError: libffi.so.6         


        
相关标签:
6条回答
  • 2021-02-06 21:43

    Its probably the libffi6 package that you want, that installs a libffi.so.6.

    sudo apt-get install libffi6
    
    0 讨论(0)
  • 2021-02-06 21:47

    I had the same problem (when I upgrded to Ubuntu 20.04) when I tried to run Jupyter Notebook.

    Step 1) --> Just re-install python3.7.6 (the version I was using) :

    $ cd path_to_python3.7_folder
    
    • Do again de installation process:
        $ ./configure --enable-optimizations
        $ make
        $ sudo make install
    

    1. Step 2: uninstall jupyter. I used pip3.7 uninstall ... See: How to uninstall Jupyter note book installed by pip3

    2. Step 3: Re-install jupyter again:

        $ pip3.7 install jupyterlab
        $ pip3.7 install notebook
    

    Try to run jupyter again. It should work.

    0 讨论(0)
  • 2021-02-06 21:48

    If you are using pyenv, you should just uninstall the used python version and then reinstall it.

    Example:

    pyenv uninstall 3.7.4
    pyenv install 3.7.4
    

    It's cleaner and safer than renaming system library from my point of view.

    0 讨论(0)
  • 2021-02-06 21:53

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

    1. Ubuntu 20.04 upgraded libffi6 to libffi7
    2. Python is still looking for libffi6

    What I did to fix it :

    Locate libffi.so.7 in your system

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

    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
    

    UPDATE:

    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.

    0 讨论(0)
  • 2021-02-06 21:53

    Same problem for me

    1. Upgraded to ubuntu 20
    2. pip didn't work anymore (same error)

    What I did was:

    1. deleted the virtual env I was using
    2. recreated it
    3. Sure, I wasn't able to do a pip freeze to get save my dependencies (as pip didn't work), but fortunately I didn't care about them.
    0 讨论(0)
  • 2021-02-06 21:58

    I am using Xubuntu 20.04 and recompiling the python version 3.7 did not work for me.

    The way I solved this was to download the 19.10 version of the package from here: http://mirrors.kernel.org/ubuntu/pool/main/libf/libffi/libffi6_3.2.1-8_amd64.deb

    and then installing it

    sudo apt install ./libffi6_3.2.1-8_amd64.deb
    

    This will unpack the libffi.so.6 and libffi.so.6.0.4 files to /usr/lib/x86_64-linux-gnu/. The libffi.so.6 file is just a link to libffi.so.6.0.4 in the same directory.

    As far as I could see this does not overwrite any files so should be safe.

    Hopefully this helps someone as well.

    0 讨论(0)
提交回复
热议问题