2017년 7월 24일 월요일

Mac Anaconda 와 Python3 환경에서 pygame 설치하는법


Mac Sierra Anaconda 와 Python3 환경에서 pygame 설치 
환경
OS : Mac OS Sierra (10.12.5)
Python Version : 3.6.1
Anaconda version : custom  
Pygame 라이브러리를 설치하기 위한 Process 정리 (작동확인)

필요사항

Xcode optional package 를 먼저 설치.
터미널에서
> xcode -select —install
설치 완료되면 계속해서 진행
anaconda-python 를 설치하면  python3 , pip 는 설치 되어 있다.
터미널에서
python —version
which python
which pip
확인해보면 /Users/~/anaconda/bin 으로  되어 있음. (~는 home계정)

Package manager 설치 (이미 설치 했으면 Pass)

Mac 에서는 Homebrew 를 대부분 설치해서 사용(dependancy 자동 해결)
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

Install Pygame

다음에서 발췌 Pygame Issue Tracker thread.
첫번째로  Mercurial version control system 을 설치해준다. :
brew install mercurial
git version control 도 설치해 준다. :
brew install git
이제 pygame dependencies 를 설치해준다. :
brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi
마지막으로 :
pip install hg+http://bitbucket.org/pygame/pygame

Test sample code (on sublime text3)

import pygame,sys

pygame.init()
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Hello Pygame World!')
while True: # main game loop
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

샘플 코드 실행시 정상 작동 확인..

이 글은 Evernote에서 작성되었습니다. Evernote는 하나의 업무 공간입니다. Evernote를 다운로드하세요.

댓글 없음:

댓글 쓰기