2016-10-22 33 views
0

在Ubuntu 16.04上,我有一個virtualenv(15.0.2)。我沒有安裝matplotlib 1.5.3,我得到這個錯誤:在Ubuntu的virtualenv上安裝matplotlib的python tk

import _tkinter # If this fails your Python may not be configured for Tk 
ImportError: libBLT.2.4.so.8.6: cannot open shared object file: No such file or directory 

感謝

+0

我有這個問題早發現,但它不」不要提起訴訟irtualenv。 –

+2

我已經解決了這個問題,這要歸功於這個http://stackoverflow.com/questions/29433824/unable-to-import-matplotlib-pyplot-as-plt-in-virtualenv/33447513輸入命令「pip uninstall matplotlib」和「pip在我的virtualenv上安裝matplotlib == 1.4.3「。 –

回答

0

我假設你使用python3。

首先,在你的python shell中鍵入help('modules')。這應該返回當前安裝的所有模塊。如果tkinter沒有在那裏列出,請嘗試以下操作:

import sysconfig 
print(sysconfig.get_paths()) 

這將打印出python查找模塊的所有路徑。 移動你的Tkinter模塊上面列出的一個文件夾(通常應該是站點包但這可能取決於你的Python建立。

如果仍然不能解決問題,請嘗試

sudo apt-get install python python-tk idle python-pmw python-imaging 

如果您在使用Ubuntu,Python庫應包括Tkinter的。因此,上面的代碼重新安裝Python。

希望我能幫上忙, Narusan

+0

對不起,數據缺失,我正在使用python 2.7.9。我確實試圖在標準的python安裝(/ usr/bin/..)中安裝matplotlib,它完美的工作,所以我想我有所有的庫。當我用我的virtualenv解釋器運行代碼時,問題就出現了。在這種情況下,tk有些問題,它不能使用命令在virtualenv上安裝: –

+0

cd .../path/to/env,source/bin/activate,pip install tk –

+0

看起來命令「sudo apt-get安裝python python-tk idle python-pmw python-imaging「確實解決了我的問題。對不起,我不能+1你的答案。非常感謝!!!! –

相關問題