Ubuntu: How do I install Pygame in virtualenv?



Question:

In installed python-virtualenv, because this question said I should use virtualenv to install pygame. However, I'm not really sure how that's accomplished.

What I did (following these instructions):

virtualenv --no-site-packages --distribute -p /usr/bin/python3.3 ~/.virtualenvs/pywork3 --no-pip  

And then I don't know where to go.

How do I install pygame to be used in the virtualenv?

Edit: I followed GuySoft's instructions, and everything installed great. However, when I tried import pygame in python3, I got the following error:

>>> import pygame  Traceback (most recent call last):    File "<stdin>", line 1, in <module>    File "/home/alden/.virtualenvs/pywork3/lib/python3.3/site-packages/pygame/__init__.py", line 95, in <module>  from pygame.base import *  ImportError: /home/alden/.virtualenvs/pywork3/lib/python3.3/site-packages/pygame/base.cpython-33m.so: undefined symbol: PyCObject_Check  


Solution:1

I suggest you have pip in your virualenv, its useful.

Note: must have pygame's dependencies installed, you can find out what they are and install them with:

sudo apt-get build-dep python-pygame  

Then try this:

rm -rf ~/.virtualenvs/pywork3 #clean what you have there  mkdir -p ~/.virtualenvs/pywork3  virtualenv --no-site-packages --distribute -p /usr/bin/python3.3 ~/.virtualenvs/pywork3  . ~/.virtualenvs/pywork3/bin/activate  pip install pygame  


Solution:2

that is working for me without problem:

sudo apt-get build-dep python-pygame  

than:

pip install hg+http://bitbucket.org/pygame/pygame  


Solution:3

I have found that pygame will not install in a virtualenv on ubuntu 15.10.

The problem is missing links to libswscale and libavformat.

On my system I added the following symlinks:

$ sudo ln -sf /usr/include/x86_64-linux-gnu/libswscale /usr/include/libswscale  $ sudo ln -sf /usr/include/x86_64-linux-gnu/libavformat /usr/include/libavformat  

At that point I was able to follow the http://pygame.org/wiki/CompileUbuntu#Installing pygame with pip instructions. I am now levitating in a ball of clear light.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »