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 · 3901 次点击
    这是一个创建于 3289 天前的主题,其中的信息可能已经有所发展或是发生改变。
    >>> 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   ·   我们的愿景   ·   实用小工具   ·   5349 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 07:25 · PVG 15:25 · LAX 00:25 · JFK 03:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.