Contents

Computer Graphics Environment Setting

   Mar 3, 2023     1 min read

1 LAB : Environment Setting

Python Interpreter

Download Python

  • Python 3.8 이상 버전 다운로드
  • 모든 과제와 프로젝트의 제출은 Python 3.8에 NumPy, PyOpenGL, glfw, PyGLM만 설치된 것으로 실행되어야한다.

Python Packages (Modules)

  • python 모듈을 설치하는데 pip(Python Package Index) 사용
pip install <package_name>

Python Virtual Environment

  • virtualenv & virtualenvwrapper 설치 (MacOS)
# Install Homebrew(package manager for mac OS) from below link.
https://brew.sh/index_ko

# if you install python3 using Homebrew, pip and pip3 would be installed automatically.
$ brew install python3

$ pip3 install virtualenv virtualenvwrapper

# Add the following line to ~/.bashrc:
export 
VIRTUALENVWRAPPER_PYTHON=/opt/homebrew/bin/python3
source /opt/homebrew/bin/virtualenvwrapper.sh

$ source ~/.bashrc

Virtualenvwrapper 사용법

# Create an environment
$ mkvirtualenv --python=PATH_TO_PYTHON ENVNAME

# Remove an environment
$ rmvirtualenv ENVNAME

# List all of the environments
$ lsvirtualenv

# Activate an environment
$ workon ENVNAME

# Deactivate the current environment
$ deactivate

environment 생성

$ mkvirtualenv --python=<python3.x> cg-course
  • Replace with your python version
  • e.g. –python=python3.8

environment 활성화

$ workon cg-course

Modules

  • 아래 명령어로 설치
$ pip install numpy pyopengl glfw pyglm
  • 또는
$ pip install numpy
$ pip install PyOpenGL
$ pip install glfw
$ pip install pyglm

Ensure Your Python Environment

  • example of a well-configured environment
$ python
Python 3.8.10 (default, Nov 142022, 12:59:47) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import OpenGL
>>> import glfw
>>> import glm
>>>

Python References

파이썬 자습서

The Python Tutorial

Python 3 Tutorial