我成功安装了一个模块但是为何用 IDLE 和 sublime text2 就提示出错? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
napretep
V2EX    Python

我成功安装了一个模块但是为何用 IDLE 和 sublime text2 就提示出错?

  •  
  •   napretep 2015-04-16 18:55:12 +08:00 4574 次点击
    这是一个创建于 3899 天前的主题,其中的信息可能已经有所发展或是发生改变。
    >>> import pyglet
    >>> pyglet.window.Window(800,600)
    Win32Window(width=800, height=600)

    这个是用windows powershell运行的,没有问题


    Traceback (most recent call last):
    File "C:\down\pyglet.py", line 1, in <module>
    import pyglet
    File "C:\down\pyglet.py", line 2, in <module>
    game_window = pyglet.window.Window(800,600)
    AttributeError: 'module' object has no attribute 'window'

    这个是st2运行的,说没有找到window属性。
    IDLE上的提示也一样。

    请问是哪里出了问题?
    7 条回复    2015-04-16 20:46:31 +08:00
    xylophone21
        1
    xylophone21  
       2015-04-16 19:01:38 +08:00
    看看你的环境是不是装了多个python,然后运行的不是同一个。
    napretep
        2
    napretep  
    OP
       2015-04-16 19:13:58 +08:00
    @xylophone21

    你是说在系统属性-高级-环境变量里看吗?

    用户变量为
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Users\napretep\.babun;c:\python27

    系统变量为
    C:\Python27\;C:\Python27\Scripts;C:\Program Files\Intel\TXE Components\TCS\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\TXE Components\DAL\;C:\Program Files\Intel\TXE Components\IPT\;C:\Program Files\Leawo\Youtube Download;

    我不知道自己装了几个,因为过去曾反复装过python3和2,现在按照记忆来看的话,应该是一个。
    xylophone21
        3
    xylophone21  
       2015-04-16 19:36:05 +08:00
    cmd及powershell里分别运行python -v

    另外参考http://docs.sublimetext.tw/others/
    napretep
        4
    napretep  
    OP
       2015-04-16 20:12:17 +08:00
    @xylophone21

    Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
    Type "copyright", "credits" or "license()" for more information.
    >>> import pyglet
    >>> pyglet.window.Window(800,600)

    Traceback (most recent call last):
    File "<pyshell#1>", line 1, in <module>
    pyglet.window.Window(800,600)
    File "C:\Python27\lib\site-packages\pyglet\window\win32\__init__.py", line 131, in __init__
    super(Win32Window, self).__init__(*args, **kwargs)
    File "C:\Python27\lib\site-packages\pyglet\window\__init__.py", line 505, in __init__
    cOnfig= screen.get_best_config(template_config)
    File "C:\Python27\lib\site-packages\pyglet\canvas\base.py", line 161, in get_best_config
    cOnfigs= self.get_matching_configs(template)
    File "C:\Python27\lib\site-packages\pyglet\canvas\win32.py", line 33, in get_matching_configs
    cOnfigs= template.match(canvas)
    File "C:\Python27\lib\site-packages\pyglet\gl\win32.py", line 25, in match
    return self._get_arb_pixel_format_matching_configs(canvas)
    File "C:\Python27\lib\site-packages\pyglet\gl\win32.py", line 98, in _get_arb_pixel_format_matching_configs
    nformats, pformats, nformats)
    File "C:\Python27\lib\site-packages\pyglet\gl\lib_wgl.py", line 95, in __call__
    result = self.func(*args, **kwargs)
    File "C:\Python27\lib\site-packages\pyglet\gl\lib.py", line 62, in MissingFunction
    raise MissingFunctionException(name, requires, suggestions)
    MissingFunctionException: wglChoosePixelFormatARB is not exported by the available OpenGL driver. ARB_pixel_format is required for this functionality.
    >>>
    xylophone21
        5
    xylophone21  
       2015-04-16 20:20:27 +08:00
    在powershell里运行

    Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
    Type "copyright", "credits" or "license()" for more information.
    >>> import pyglet
    >>> pyglet.window1.Window(800,600)

    注意这个1,让它报类似的错误,你就可以看到powershell里用的是哪个路径下的pyglet了
    laike9m
        6
    laike9m  
       2015-04-16 20:38:03 +08:00
    试试这个呢,用 wheel 来装
    http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyglet
    napretep
        7
    napretep  
    OP
       2015-04-16 20:46:31 +08:00
    @xylophone21

    应该是同一个python吧。
    cmd 和powershell输入 python -v 得到的目录都是在c:\python27里的

    好在我用刚下了的pycharm没什么问题。
    那这个问题就先放着还是最好解决掉啊?
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2844 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 14:37 PVG 22:37 LAX 06:37 JFK 09:37
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86