问题
I am excited to use Pyglet because of all its features, however I am having problems installing the latest development build of Pyglet on Python 3. I am aware people have already asked this question but none of the responses helped me at all.
UPDATE: What I mean is that I am unable to get Pyglet to install for Python 3, whenever I import Pyglet it showss an error message with some Python 2 code.
回答1:
Install using the below command:
pip3 install pyglet
This worked for me.
回答2:
Instead of installing pyglet you can also put a copy of pyglet in the project folder and import it from there. This approach makes it also easy to use different versions of pyglet for your projects.
To make pyglet running on python 3 you need to convert the latest version of pyglet using 2to3. Without that conversion it will not run on python 3. With previous versions of pyglet you will have difficulties when trying to convert it so make sure to use 1.2 (which is currently at alpha state but quite stable).
回答3:
I used:
pip3 install pyglet
and it works perfectly. Make sure that when you run python from the terminal you use
python3
and not
python
because that messed it up for me at first.
回答4:
The solution is to pip install from the rep, e.g. using
pip install -e hg+https://pyglet.googlecode.com/hg/@2813:0aa8bfe3313a#egg=pyglet
this is because the current version of pyglet in pip is not compatible with python 3 yet.
回答5:
I applied the answer of @J. C. Leitão to Ubuntu 14.04.
sudo apt-get install python3-git mercurial
sudo pip3 install -e hg+https://pyglet.googlecode.com/hg/@2813:0aa8bfe3313a#egg=pyglet
And now I can import pyglet.
(However it seems to not work properly. If I run the hello world program the Hello world can not bee seen in the window. I can see just darkness in it.)
回答6:
I think it's because you want to use it with python3 and you are installing it with pip, which is for python2, pip3 is for python3.
回答7:
If you are installing using pip, try typing pip3 install pyglet and it will install for python 3 instead of python 2. (Any time you want to install for python3, use pip3 instead of pip)
If it is installed correctly, make sure you save the python file in the same folder that you have pyglet installed. If it is not installed and you don't have the path set up, it won't import.
回答8:
If you have pip installed, then it should be easy, just use "pip install pyglet". Else install pip, it makes installing python packages a lot easier.
来源:https://stackoverflow.com/questions/21298834/how-to-get-pyglet-working-for-python-3