简体   繁体   中英

How to solve import cv2 import error on Amazon linux?

I am using an Amazon linux machine with python 2.7. I am working with Anaconda. When typing:

import cv2

I get the following exception:

ImportError: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory

I have tried to search online but did not find a solution for amazon linux.

Thanks.

I have followed instructions in this page and worked fine: https://ubunifu.co/python/installing-libgtk-x11-2-0-so-0-in-amazon-linux-ami-2017-03-1

$ sudo yum install ftp://ftp.riken.jp/Linux/centos/6/os/x86_64/Packages/hicolor-icon-theme-0.11-1.1.el6.noarch.rpm
$ sudo yum install ftp://ftp.riken.jp/Linux/centos/6/os/x86_64/Packages/atk-1.30.0-1.el6.x86_64.rpm
$ sudo yum install ftp://ftp.riken.jp/Linux/centos/6/os/x86_64/Packages/gdk-pixbuf2-2.24.1-6.el6_7.x86_64.rpm
$ sudo yum install ftp://ftp.riken.jp/Linux/centos/6/os/x86_64/Packages/gtk2-2.24.23-9.el6.x86_64.rpm

As it seems Amazon AMI doesn't have a yum repository for the libgtk-x11-2.0.so.0. So, we can install it from CentOs distro packages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM