libpython2.7.so.1.0 cannot open的解决方法
使用源代碼的方式安裝Python2.7之后,在import某些庫時拋出了如下異常:
ImportError:?libpython2.7.so.1.0:?cannot?open?shared?object?file:?No?such?file?or?directory
一?原因分析
????由于在系統的lib路徑中找不到這個共享庫。
注:?如果編譯時加上了--enable-shared,才會編譯這個共享庫,默認的位置是python可執行程序所在目錄的lib目錄下,如/usr/local/python27
二?解決方法
??1.?可以使用如下方式編譯Python以解決這個問題:
????./configure?--enable-shared?--prefix=/usr/local/python27
????make?&&?make?install
??2.?cp?/usr/local/python27/lib/libpython2.7.so.1.0?/usr/local/lib
?????cd?/usr/local/lib
?????ln?-s?libpython2.7.so.1.0?libpython2.7.so
??3.?使用命令whereis?libpython2.7.so.1.0得到如下結果就說明
????libpython2.7.so.1:?/usr/local/lib/libpython2.7.so.1.0
??4.?如果whereis沒有結果,或者還有import錯誤,可以嘗試如下操作:
????在/etc/ld.so.conf中加入新行/usr/local/lib
????保存后,運行
????/sbin/ldconfig
????/sbin/ldconfig?–v
?
轉載于:https://blog.51cto.com/newlight/1379511
總結
以上是生活随笔為你收集整理的libpython2.7.so.1.0 cannot open的解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 转:如何进行软件架构设计?
- 下一篇: 自反ACL