Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

After following the instructions How do I install Pygame in virtualenv?, running `pip install pygame' now returns:

Downloading/unpacking pygame
Running setup.py egg_info for package pygame
Skipping module _numericsurfarray for Python 3.2.3 (default, Apr 10 2013, 06:11:55)
[GCC 4.6.3] build.
Skipping module _numericsndarray for Python 3.2.3 (default, Apr 10 2013, 06:11:55)
[GCC 4.6.3] build.
Skipping module scrap for Python 3.2.3 (default, Apr 10 2013, 06:11:55)
[GCC 4.6.3] build.
Skipping module _camera for Python 3.2.3 (default, Apr 10 2013, 06:11:55)
[GCC 4.6.3] build.

warning: no files found matching 'readme.txt'
no previously-included directories found matching '*/CVS'
no previously-included directories found matching '*/*/CVS'
Installing collected packages: pygame
Running setup.py install for pygame
Skipping module _numericsurfarray for Python 3.2.3 (default, Apr 10 2013, 06:11:55)
[GCC 4.6.3] build.
Skipping module _numericsndarray for Python 3.2.3 (default, Apr 10 2013, 06:11:55)
[GCC 4.6.3] build.
Skipping module scrap for Python 3.2.3 (default, Apr 10 2013, 06:11:55)
[GCC 4.6.3] build.
Skipping module _camera for Python 3.2.3 (default, Apr 10 2013, 06:11:55)
[GCC 4.6.3] build.
building 'pygame.imageext' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -D_REENTRANT -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/SDL -I/usr/include -I/usr/include -I/usr/include/python3.2mu -c src/imageext.c -o build/temp.linux-x86_64-3.2/src/imageext.o
In file included from src/imageext.c:47:0:
src/pygame.h:75:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/david/.virtualenvs/pywork3/bin/python3.2 -c "import setuptools;__file__='/home/david/.virtualenvs/pywork3/build/pygame/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-0tu3l3-record/install-record.txt --install-headers /home/david/.virtualenvs/pywork3/include/site/python3.2:
Skipping module _numericsurfarray for Python 3.2.3 (default, Apr 10 2013, 06:11:55)

[GCC 4.6.3] build.

Skipping module _numericsndarray for Python 3.2.3 (default, Apr 10 2013, 06:11:55)

[GCC 4.6.3] build.

Skipping module scrap for Python 3.2.3 (default, Apr 10 2013, 06:11:55)

[GCC 4.6.3] build.

Skipping module _camera for Python 3.2.3 (default, Apr 10 2013, 06:11:55)

[GCC 4.6.3] build.

running install

running build

running build_py

running build_ext

building 'pygame.imageext' extension

gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -D_REENTRANT -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/SDL -I/usr/include -I/usr/include -I/usr/include/python3.2mu -c src/imageext.c -o build/temp.linux-x86_64-3.2/src/imageext.o

In file included from src/imageext.c:47:0:

src/pygame.h:75:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /home/david/.virtualenvs/pywork3/bin/python3.2 -c "import setuptools;__file__='/home/david/.virtualenvs/pywork3/build/pygame/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-0tu3l3-record/install-record.txt --install-headers /home/david/.virtualenvs/pywork3/include/site/python3.2 failed with error code 1 in /home/david/.virtualenvs/pywork3/build/pygame
Storing complete log in /home/david/.pip/pip.log

Thoughts?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

fatal error: Python.h: No such file or directory

Indicates to me that you haven't installed the Python development (headers) package. For Python 2.7 (the default), this is included in python-dev Install python-dev, for the Python 3.2 version you seem to be using this is python3.2-dev Install python3.2-dev. Note that this will only work if you installed Python 3.2 from the Ubuntu packages.

After installation, try again to install the Python package.


The new error you're getting,

error: could not create '/usr/local/lib/python3.2/dist-packages/pygame': Permission denied`

could be because of two reasons:

  • You're not working in a Python virtualenv. Without working in a virtualenv, it will try to install in the system folders (/usr/local/ etc.). Solution: switch to the virtualenv properly, e.g. workon <virtualenvname> and run the pip commands in the same terminal window.

    OR, if you don't intend to work with virtualenvs:

  • You're trying to install it system-wide, but you didn't elevate your privileges to do so. Solution: prepend the pip command with sudo, e.g.

    sudo pip install pygame
    
share|improve this answer
    
New error: paste.ubuntu.com/5801725 –  David Y. Stephenson Jun 26 '13 at 14:59
    
@DavidY.Stephenson See my updated question. Do you know what a virtualenv is? If not, see the reason at the bottom. –  gertvdijk Jun 26 '13 at 15:06
    
Thank you very much. I do plan on using a virtualenv, (I'm learning about them as part of this process). How do I install python-dev from within the virtuaenv? sudo apt-get install python-dev after activating says it is already installed. –  David Y. Stephenson Jun 26 '13 at 15:14
    
@DavidY.Stephenson Read up on virtualenvs. The Python interpreter is usually shared with the global system one, so there's no need to install specific headers inside the paths of the virtualenv. Just install Python and the development package once, globally (Ubuntu apt-get packages). The Python packages (pip/easy_install) should go in the virtualenv. –  gertvdijk Jun 26 '13 at 15:17
    
@DavidY.Stephenson Also, if this answer is helpful and solved your issue, consider accepting it. Thanks. –  gertvdijk Jun 26 '13 at 15:20
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.