Lo ejecuté brew install pygame
, lo instalé junto con todas las dependencias. Python v2.7.10 / OS X versión 10.11.2
Cada vez que import pygame
en un guión dice esto
Traceback (most recent call last):
File "~/Documents/test.py", line 1, in <module>
import pygame, random, sys
ImportError: No module named pygame
¿Cómo puedo solucionar esto?
¿Ha comprobado qué python está ejecutando: el python del sistema o el que instaló a través de homebrew? Sospecho lo primero.
Como prueba, intente ejecutar
/usr/local/Cellar/python/2.7.10/bin/python
y escribiendo
>> import pygame
Si esto funciona, puede hacer que la versión de preparación sea la predeterminada usando:
brew link python
Después de instalarme brew install pygame
, escupe este mensaje:
==> python -c import setuptools... --no-user-cfg install --prefix=/usr/local/Cellar/pygame/1.9.2a0 --single-version-externally-managed --record=installed.txt
==> Caveats
Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
mkdir -p /Users/packrd/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/packrd/Library/Python/2.7/lib/python/site-packages/homebrew.pth
lo que aparentemente significaba "instalamos esto, pero su python no podrá usarlo"
La rareza aquí parece ser que si brew install pygame
lo hace, no instalará python, solo pygame (¿para que las dependencias las usen?)
Entonces, siga esas instrucciones (como están impresas en su pantalla) y luego funciona, o haga brew install python
y use ese python en su lugar (/usr/local/bin/python en lugar de /usr/bin/python).
Nombre para mostrar
cris