2013-10-20 58 views
2

我在Ubuntu 12.04 LTS(http://code.google.com/p/cefpython/)中安裝了cefpython的64位軟件包。問題是我無法運行這些示例。它說沒有名爲wx的模塊。 但是,當我導航到目錄/usr/local/lib/python2.7/dist-packages/cefpython1,並導入wx它的作品。所以基本上我無法在該目錄之外導入wx。我在終端上使用python解釋器。只能夠在安裝目錄中導入python模塊

rishi:cefpython1 ls 
cefclient   cefpython_py27.pyc chrome.pak    examples  __init__.pyc LICENSE.txt wx 
cefpython_py27.py cefpython_py27.so devtools_resources.pak __init__.py libcef.so  locales 
rishi:cefpython1 python 
Python 2.7.3 (default, Sep 26 2013, 20:03:06) 
[GCC 4.6.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import wx 
>>> 
[2]+ Stopped     python 
rishi:cefpython1 cd .. 
rishi:dist-packages python 
Python 2.7.3 (default, Sep 26 2013, 20:03:06) 
[GCC 4.6.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import wx 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named wx 
>>> 
KeyboardInterrupt 
>>> 

我的路徑如下所示和PYTHONPATH是空的:在Ubuntu cefpython的 安裝64位包12.04 LTS(http://code.google.com/p/cefpython/)。問題是我無法運行這些示例。它說沒有名爲wx的模塊。但是,當我導航到/usr/local/lib/python2.7/dist-packages/cefpython1目錄並導入wx時,它會起作用。所以基本上我無法在該目錄之外導入wx。我在終端上使用python解釋器。

rishi:dist-packages echo $PATH 
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games 
rishi:dist-packages echo $PYTHONPATH 

rishi:dist-packages echo $PYTHONPATH 

rishi:dist-packages 
+0

你的'PATH'和'PYTHONPATH'是什麼樣的? –

+0

@SnakesandCoffee更新。 PYTHONPATH是空的。 – rishiag

+0

我的PYTHONPATH也是空的,例子工作正常。我已經通過Ubuntu軟件中心安裝了「python-wxtools」軟件包來安裝wx庫,您可以試試看。 –

回答

1

你的問題在於,python不知道你從哪裏導入。有關說明,請參閱This post。基本上,發生的事情是,當你在目錄中時,python知道要查找它(它在目錄中查找python文件和包)。您需要將python庫添加到PYTHONPATH中。