No module named pyglet

时间秒杀一切 提交于 2020-01-24 15:48:08

问题


I'm having a strange issue with pyglet. After running pip install pyglet and restarting my command line application, I'm still unable to run a python script that imports pyglet.

Error output:

$ python main.py
Traceback (most recent call last):
  File "main.py", line 6, in <module>
    from pyglet import image
ImportError: No module named pyglet

Running pip install pyglet again gives:

pip install pyglet
--> Requirement already satisfied (use --upgrade to upgrade): 
    pyglet in c:\python34\lib\site-packages

This is on a Windows 7 machine running Python 2.7, and the script in question can be found here: https://github.com/fogleman/Minecraft/blob/master/main.py

What's the matter with pyglet?


回答1:


This line

pyglet in c:\python34\lib\site-packages
                   ^    

means that you installed module for python 3.4. You need to install it for 2.7 instead:

python2.7 -m pip install pyglet

or, which is more reliable in your case

python -m pip install pyglet


来源:https://stackoverflow.com/questions/31613258/no-module-named-pyglet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!