【问题标题】:no module named gtk没有名为 gtk 的模块
【发布时间】:2012-09-20 10:26:49
【问题描述】:

为什么我用 homebrew 安装 gtk & pygtk,但是 python 还是找不到:

brew test -v pygtk
Testing pygtk
==> chmod +x test.py
chmod +x test.py 
==> ./test.py
./test.py 
Traceback (most recent call last):
  File "./test.py", line 2, in <module>
    import pygtk
ImportError: No module named pygtk
Error: pygtk: failed

【问题讨论】:

    标签: python gtk pygtk homebrew


    【解决方案1】:

    检查模块是否在您的 python 路径中。检查您安装软件包的位置并将其添加到您的 bashrc 中,

    #.bashrc        
    PATH=$PATH:$HOME/bin:/opt/lib/python2.4/site-packages/psycopg2/:path_to_module
    export PATH 
    

    【讨论】:

      【解决方案2】:

      这些库不在 PYTHONPATH 中。我会尝试:

      $ export PYTHONPATH=/usr/local/lib/python2.7/site-packages
      

      【讨论】: