python程式解壓rar壓縮包報錯

來源:互聯網
上載者:User

標籤:class   變數   bash   /etc   src   python程式   from   coding   成功   

運行如下python程式報錯Couldn't find path to unrar library的解決辦法:

#!/usr/bin/python#-*- coding:utf-8 -*-from unrar import rarfilefile = rarfile.RarFile('/root/ssl.rar')file.extractall('/tmp')

備忘:rarfile已經通過pip3 install rarfile安裝,但是unrar用pip3雖然提示成功但是有問題,所以手動安裝下unrar包。




1、安裝依賴包

yum install gcc gcc-c++



2、下載unrar包、安裝、編譯

wget http://www.rarlab.com/rar/unrarsrc-5.4.5.tar.gztar zxf unrarsrc-5.4.5.tar.gzcd unrar


使用make lib命令將會自動編譯庫檔案,再使用make install-lib命令產生 libunrar.so 檔案(一般在 /usr/lib 目錄下面)

make libmake install-lib




3. 在/etc/profile檔案末尾加上

vi /etc/profileexport UNRAR_LIB_PATH=/usr/lib/libunrar.so成功儲存後再使用命令使變數生效source /etc/profile


python程式解壓rar壓縮包報錯

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.