2017-06-13 44 views
0

每當我運行任何python2程序或打開python解釋器時,出現以下錯誤。在ubuntu14.04的python2.7中導入錯誤

$~/python> python setup.py 
Could not find platform independent libraries <prefix> 
Could not find platform dependent libraries <exec_prefix> 
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] 
Could not find platform independent libraries <prefix> 
Could not find platform dependent libraries <exec_prefix> 
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] 
ImportError: No module named site 

當我用下面的命令

$ export PYTHONPATH=/usr/local/lib/python2.7 

我收到以下錯誤

ImportError: No module named site 

我也曾嘗試重新安裝Python的使用下面的命令

sudo apt-get install --reinstall python 

但它有助於所有。

在此先感謝。

回答

0

export PYTHONHOME =/usr/local。 Python應該安裝在OS X的/ usr/local目錄下。

+0

你的最後一行有點偏離主題。用戶在ubuntu中出現錯誤,並且您在OS X – Gahan

+0

上建議了一些東西我修正了錯誤。我用'$ export PYTHONPATH =/usr/lib/python2.7'激活了以下命令。 /usr/local/lib/python2.7是python虛擬環境的地址。但是,只要我重新啓動我的ubuntu,_error就會重新出現。我怎樣才能永久解決這個錯誤,以及如何爲python3設置PYTHOPATH。 @Gahan @praneet drolia –

+0

嘗試使用anaconda設置python – Gahan