2

I have two Ubuntu VMs. On one of them, I can't seem to install PyGame. I've tried installing through various methods:

  • sudo apt-get install python-pygame
  • (Remove and reinstall pygame a couple times)
  • Building from source (also fails)
  • Using pip (also fails)

The core issue seems to be that when I import pygame with Python 2, I get No module named pygame error. (I get the same thing with Python 3, but I'm not trying to make this work with Python 3.)

I looked at various SO/SE/AU questions, including this one and a couple of others.

Is there a way to troubleshoot this deeper and/or resolve whatever the issue is? I would like to figure out how to get this working with apt-get.

On another similar VM, PyGame installs fine through apt-get.

Edit: The response to python -c 'import sys; print "\n".join(sys.path)' is the following, which is something I set up for MRuby ages ago (and need to nuke):

/home/ashiq/Desktop/my-android-toolchain/lib/python27.zip
/home/ashiq/Desktop/my-android-toolchain/lib/python2.7
/home/ashiq/Desktop/my-android-toolchain/lib/python2.7/plat-linux2
/home/ashiq/Desktop/my-android-toolchain/lib/python2.7/lib-tk
/home/ashiq/Desktop/my-android-toolchain/lib/python2.7/lib-old
/home/ashiq/Desktop/my-android-toolchain/lib/python2.7/lib-dynload
/home/ashiq/Desktop/my-android-toolchain/lib/python2.7/site-packages

Further edits: After deleting my-android-toolchain and removing it from the path (from .bashrc), I can import pygame.

ashes999
  • 177

1 Answers1

2

Looks like you built or installed a custom Python in your home directory (~/Desktop/my-android-toolchain).

Probably this custom Python installation shadows the system Python. You can check which executable is getting run using the command

which python

It should report something like /usr/bin/python. This is the system's Python installation that is preinstalled and which is maintained by your package manager (apt).

If you use that to install Python packages or if you use this installation's pip, they will all install their modules in the system's Python installation. Anything there will not affect your custom Python installation in your home directory, as you see that it has only its own library paths.

You should either remove your custom my-android-toolchain Python installation or make sure that you are running the system's Python /usr/bin/python by default.

Byte Commander
  • 110,243