1

Im trying to install pygame on spyder but i tried everything and nothing works. Anaconda is installed i have tried pip, conda but every time when i import it i get the error no module named pygame. When i try conda install -c https://conda.binstar.org/tlatorre pygame the following error appears:

UnsatisfiableError: The following specifications were found to be in conflict:
  - pygame -> python 2.7* -> openssl 1.0.1*
  - python 3.6**

I have tried other addresses as well but i get the same error. How do i do it? Use conda info <package> to see the dependencies for each package.

So I want this to work specidically in the newest version of spyder(spyder3)(maybe with pythonpathmanager).

  • Same problem here. It is possible, but a pain in the ass. See my answer. – neuronet Jun 28 '17 at 22:38
0

Im trying to install pygame on spyder

&

So i want this to work specidically in the newest version of spyder(spyder3)(maybe with pythonpathmanager

You don't install Pygame for Spyder, it's a Python module, so you install it for a particular Python interpreter (or for various).

i have tried pip, conda but every time when i import it i get the error no module named pygame

There's nothing to import, you never installed the module because of UnsatisfiableError.

UnsatisfiableError: The following specifications were found to be in conflict: - pygame -> python 2.7 -> openssl 1.0.1* - python 3.6**

That particular conda package you are trying to download seems to depend on python 2.7, if you download the tarball, you can check the info/index.json file, it marks python 2.7* as dependency.

Installing with pip

1) Activate the virtual environment where you want to install Pygame or, if you are not using environments, make sure that you are using the Python interpreter for which you want to install the module, do this with which python, it should point to your intended interpreter.

Note: The location to where pip installs modules depends on the selected Python interpreter. The Python interpreter you use and the launched spyder instance depend on their precedence on your PATH. If you use environments, these aren't problems, because the env tool (conda, venv, virtualenv, &c) will modify the PATH as needed.

2) pip install pygame, add sudo if you intend to install for the system's default interpreter on /usr/bin/python.

That's it, you should be able to import it.


Additional notes:

If you are interested in using the PyPi package (this is what pip installs), but manage it with conda, then you need to build a conda package.

If you have already installed Pygame somewhere and wants to use it with a Python interpreter that doesn't know about it, you can use the PYTHONPATH environment variable to let Python know from where else it can try to find it. This may not be such a good idea depending on the situation.

0

It should be easy but there is no conda installer built for it.

Python 2

At command line

sudo apt-get install python-pygame

Python 3

It's a bit of a pain in the butt you have to install some dependencies, and then Pygame. First do the following:

sudo apt-get install python3-dev mercurial
sudo apt-get install libsdl-image1.2-dev libsdl2-dev libsdl-ttf2.0-dev
sudo apt-get install libsdl-mixer1.2-dev libportmidi-dev
sudo apt-get install libswscale-dev libsmpeg-dev libavformat-dev libavcodec-dev

Make sure numpy is up to date:

conda install numpy

Then you can finally install Pygame:

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

To make sure it works just enter, at the command line:

python3
import pygame

Worked for me. This is from the website for the Python Crash course book: https://ehmatthes.github.io/pcc/chapter_12/README.html

0

Update:

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

Not work for most user because they downloaded the lastest version of pip and python. So, use this.

pip3 install --user hg+http://bitbucket.org/pygame/pygame

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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