2013-10-20 41 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中。