Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing pygame module in anaconda mac

I have Anaconda installed on my mac. And it has messed with my pygame module.

I tried following this tutorial and replacing pip3 install pygame with conda install pygame. I have tried conda install pip and then pip install pygame yet i get the following error:

Collecting pygame
  Could not find any downloads that satisfy the requirement pygame
  Some externally hosted files were ignored as access to them may be unreliable (use --allow-external pygame to allow).
  No distributions at all found for pygame

(ideas i got from this thread)

Using the "pip install pygame" worked before i did the "conda install pip" however my default python is now the anaconda one and no longer accesses pygame. Using which pip gives /Users/jensdonlin/anaconda/bin/pip

Does anyone have some suggestions that would allow anaconda's version of python3 to access pygame?

Perhaps the answer involves use --allow-external pygame to allow but im not really sure how to use that.

like image 977
JensD Avatar asked Mar 19 '15 04:03

JensD


People also ask

Can you install pygame on Mac?

Pygame is a set of Python modules used for writing simple video games and graphical programs. It is cross-platform, which means it can be installed on both Windows and Mac computers.

How do I fix No module named pygame on Mac?

Conclusion # The Python "ModuleNotFoundError: No module named 'pygame'" occurs when we forget to install the pygame module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install pygame command.

How do I import pygame modules?

Open a terminal, and type 'sudo apt-get install idle pygame', enter your password and type 'y' at the prompts, if necessary. 2. After the installation completes, enter 'python' in the terminal to launch Python. Verify that it's using version 2.7 or newer, then at the Python prompt enter 'import pygame'.


2 Answers

After 2 days of messing around with macports and homebrew with no joy, the instructions here worked for me using Anaconda Python 2.7.10 on a mac. Echoing them here in case the linked site ever disappears!

First open up terminal and enter these two lines:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install sdl sdl_ttf sdl_image sdl_mixer portmidi

If you don't have binstar installed type:

conda install binstar

At this point it might tell you that The 'binstar' conda package has been renamed to 'anaconda-client' and that you have to type this instead:

conda install anaconda-client

Just do whatever it tells you to. Then finally, type:

conda install -c https://conda.binstar.org/quasiben pygame

and hopefully you're done!

like image 92
vahndi Avatar answered Sep 23 '22 03:09

vahndi


The problem here is that the pygame developers have not uploaded pygame to PyPI. So to install it, you will have to download it and pip install the downloaded source, as described in the tutorial you linked. You can do this within the Anaconda Python. Note that in the Anaconda Python, even if it is Python 3, pip is just called pip, not pip3.

like image 26
asmeurer Avatar answered Sep 23 '22 03:09

asmeurer