Python のインストール
ダウンロード
http://www.python.org/ の公式配布バイナリを使う。
- Python 2.7.10 - Windows 32bit
- Python 2.7.10 - Windows 64bit
- Python 3.4.3 - Windows 32bit
3.4 の 64bit は割愛
http://pypy.org/ のPyPyも試しに入れてみる
- PyPy 2.6.0 Windows 32bit
インストール
CPython は普通にインストーラを実行。ただし、どのバージョンでも「Add To PATH」は選択しないでおく。
PyPyはC:\PyPy26に展開した。
virtualenv のインストール
C:\>c:\python27\scripts\pip install virtualenv
[33mYou are using pip version 7.0.1, however version 7.1.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.[0m
Collecting virtualenv
Downloading virtualenv-13.1.0-py2.py3-none-any.whl (1.7MB)
[K 100% |################################| 1.7MB 236kB/s eta 0:00:01
Installing collected packages: virtualenv
Successfully installed virtualenv-13.1.0
virtualenv を使う
例では全部 venv
という名前で作っているがわかりやすい名前にした方が良いかも。
Python 2.7
C:\Users\kounoike\Documents\python\py27>venv\Scripts\activate.bat
(venv) C:\Users\kounoike\Documents\python\py27>python --version
Python 2.7.10
(venv) C:\Users\kounoike\Documents\python\py27>python
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
Python 2.7-64bit
C:\Users\kounoike\Documents\python\py64>c:\python27\Scripts\virtualenv.exe -p c:\Python27_64\python.exe venv
Running virtualenv with interpreter c:\Python27_64\python.exe
New python executable in venv\Scripts\python.exe
Installing setuptools, pip, wheel...done.
C:\Users\kounoike\Documents\python\py64>venv\Scripts\activate.bat
(venv) C:\Users\kounoike\Documents\python\py64>python --version
Python 2.7.10
(venv) C:\Users\kounoike\Documents\python\py64>python
Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
Python 3.4
C:\Users\kounoike\Documents\python\py34>c:\Python27\Scripts\virtualenv.exe -p c:\Python34\python.exe venv
Running virtualenv with interpreter c:\Python34\python.exe
Using base prefix 'c:\\Python34'
New python executable in venv\Scripts\python.exe
Installing setuptools, pip, wheel...done.
C:\Users\kounoike\Documents\python\py34>venv\Scripts\activate.bat
(venv) C:\Users\kounoike\Documents\python\py34>python --version
Python 3.4.3
(venv) C:\Users\kounoike\Documents\python\py34>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
pypy
C:\Users\kounoike\Documents\python\pypy>c:\python27\Scripts\virtualenv.exe -p c:
\pypy26\pypy.exe venv
Running virtualenv with interpreter c:\pypy26\pypy.exe
New pypy executable in venv\bin\pypy.exe
Installing setuptools, pip, wheel...done.
C:\Users\kounoike\Documents\python\pypy>venv\bin\activate.bat
(venv) C:\Users\kounoike\Documents\python\pypy>where python
C:\Users\kounoike\Documents\python\pypy\venv\bin\python.exe
(venv) C:\Users\kounoike\Documents\python\pypy>python --version
Python 2.7.9 (295ee98b6928, May 31 2015, 14:07:43)
[PyPy 2.6.0 with MSC v.1500 32 bit]
venv\bin\activate.bat
なことに注意
numpy などのコンパイル必要なライブラリをバイナリパッケージで使う
Unofficial Windows Binaries for Python Extension Packages のバイナリパッケージを使う。
良く使うもの
- numpy (matplotlib や pandas に使う)
- pywin32 (PyInstaller に使う)
URL 直リンクを好まないようなので、ダウンロードして分かりやすいフォルダに整理しておいておく(と言いながらこの後の例ではDownloads直下に入れてるけど)。
PyPyの場合はまた別のめんどくさい手順が必要みたいなのでライブラリについては割愛。