本文介绍了没有名为pyglet的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个pyglet的奇怪问题。运行 pip install pyglet 并重新启动命令行应用程序后,我仍然无法运行导入pyglet的python脚本。

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.

错误输出:

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

运行pip install pyglet再次给出:

Running pip install pyglet again gives:

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

这是在运行Python 2.7的Windows 7计算机上,有问题的脚本可以在这里找到:

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

pyglet有什么问题?

What's the matter with pyglet?

推荐答案

这一行

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

表示您为python 3.4安装了模块。你需要安装它来代替2.7:

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

这篇关于没有名为pyglet的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 23:45