Visual StudioでPyramidフレームワークを使ってみる
環境
- Windows 8.1
- Visual Studio 2015
- Python Tools for Visual Studio 2.2
- Python 3.4.2(Web PIでインストール)
参考
- Pyramid Web アプリケーション開発フレームワーク — The Pyramid Web Application Development Framework v1.4.3 (翻訳)
- Web Project · Microsoft/PTVS Wiki · GitHub
Visual StudioからPyramid起動できないかなと実験したのでメモ。
Visual Studioで空のPython Webプロジェクトを作る。
[テンプレート]-[他の言語]-[Python]-[Web Project]今回はTestProjectとした。
作成されたプロジェクトのPython Enviromentsを右クリックするとvirtualenv作れる。インポートもできる。結構便利。
Add Virtual Enviroment...クリックしてPyramid用にenvという名前で作成。
できたらActivate Enviroment。(自動でActivateされたかも)
Pyramidのインストール
Activateした環境を右クリックして、Install Python Package...
GUIでpipとかeasy_install叩けるけど、コマンドプロンプトで作業した方が楽かもしれない。
Open Command Prompt Here...からプロンプトプロンプトを開いて
Scripts\activate.bat pip install pyramid
プロジェクトのプロパティを開いてRun ServerとDebug Serverそれぞれ設定
Run Server
Command: (virtualenvまでのパス)\scripts\pserve-script.py (script) Arguments:production.ini
Debug Server
Command: (virtualenvまでのパス)\scripts\pserve-script.py (script) Arguments:development.ini
設定後、右クリックで実行できるようになる。
ちょっとはまったところ
Fatal error in launcher: Unable to create process using""(省略)""
pcreateでテンプレート作成しようとしたときに出た。
Documents\Visual Studio 2015\Projectsのようにパスにスペースが含まれるとダメらしい。
pkg_resources.DistributionNotFound: waitress
setup.pyでrequiresに指定されているものは入れないといけないっぽい。