{"id":17398,"date":"2015-05-05T08:00:32","date_gmt":"2015-05-04T23:00:32","guid":{"rendered":"http:\/\/www.sssg.org\/blogs\/hiro345\/?p=17398"},"modified":"2015-06-05T21:08:00","modified_gmt":"2015-06-05T12:08:00","slug":"2015%e5%b9%b45%e6%9c%88%e7%89%88-python%e3%81%ae%e9%96%8b%e7%99%ba%e7%92%b0%e5%a2%83%e3%82%92ubuntu%e3%81%ab%e6%a7%8b%e7%af%89","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/17398.html","title":{"rendered":"2015\u5e745\u6708\u7248 Python\u306e\u958b\u767a\u74b0\u5883\u3092Ubuntu\u306b\u69cb\u7bc9"},"content":{"rendered":"<p>\u300c<a type=\"amzn\" asin=\"4774173207\">Python\u30a8\u30f3\u30b8\u30cb\u30a2\u990a\u6210\u8aad\u672c\uff3b\u3044\u307e\u3069\u304d\u306e\u958b\u767a\u30ce\u30a6\u30cf\u30a6\u6e80\u8f09\uff01\uff3d (Software Design plus) <\/a>\u300d\u3092\u8aad\u307f\u306a\u304c\u3089\u30012015\u5e745\u6708\u7248 Python\u306e\u958b\u767a\u74b0\u5883\u3092Ubuntu\u306b\u69cb\u7bc9\u3092\u3057\u3066\u307f\u3066\u3044\u307e\u3059\u3002<br \/>\n<!--more--><br \/>\nPython\u3092\u4f7f\u3063\u3066\u3061\u3087\u3063\u3068\u3057\u305f\u958b\u767a\u3092\u3059\u308b\u3053\u3068\u3082\u5897\u3048\u3066\u304d\u3066\u3044\u308b\u306e\u3067\u30012015\u5e745\u6708\u6642\u70b9\u3067\u306e\u74b0\u5883\u306b\u3064\u3044\u3066\u6574\u7406\u3092\u3057\u3066\u3044\u307e\u3059\u3002\u7c21\u5358\u306b\u3044\u3046\u3068\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306b\u306fpip\u3092\u4f7f\u3046\u306e\u304c\u826f\u3044\u305d\u3046\u3067\u3059\u3002\u30a2\u30d7\u30ea\u3067\u5229\u7528\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u7ba1\u7406\u3092\u3059\u308b\u306b\u306f\u3001virtualenv\u3092\u4f7f\u3063\u3066\u74b0\u5883\u3092\u7528\u610f\u3059\u308b\u306e\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002virtualenv\u3067\u7528\u610f\u3057\u305f\u74b0\u5883\u3092\u3088\u308a\u4f7f\u3044\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u306e\u30b3\u30de\u30f3\u30c9\u30c4\u30fc\u30eb\u304cvirtualenvwrapper\u3068\u3057\u3066\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u4f7f\u3046\u3068\u306a\u304a\u826f\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u958b\u767a\u74b0\u5883\u306f\u3001PyCharm\u3068\u3044\u3046\u306e\u304c\u3042\u308b\u305d\u3046\u3067\u3059\u3002Eclipse + PyDev \u306f\u6700\u8fd1\u306f\u6d41\u884c\u3063\u3066\u3044\u306a\u3044\u306e\u3067\u3059\u304b\u306d\u3002Ninja IDE \u3068\u304b\u3001Spyder \u3082\u826f\u3055\u305d\u3046\u306a\u306e\u3067\u3059\u3051\u3069\u306d\u3002IDLE\u3082\u6709\u540d\u306a\u306e\u3067\u3059\u304c\u3001\u672c\u683c\u7684\u306a\u958b\u767a\u3068\u306a\u308b\u3068\u4f7f\u3063\u3066\u3044\u308b\u4eba\u306f\u3044\u306a\u3044\u306e\u3067\u3057\u3087\u3046\u304b&#8230;<\/p>\n<p>Raspberry Pi\u3067\u306fPython\u304c\u3088\u304f\u4f7f\u308f\u308c\u308b\u306e\u3067\u3001Raspberry Pi\u7528\u306eWeb\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u305f\u3044\u3068\u304d\u306b\u306f\u3001Python\u306eWeb\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3046\u306f\u305a\u3067\u3059\u3002\u3042\u308b\u66f8\u7c4d\u306b\u306fFlask\u304c\u7d39\u4ecb\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u300cPython\u30a8\u30f3\u30b8\u30cb\u30a2\u990a\u6210\u8aad\u672c\u300d\u3067\u306fBottle\u306b\u3064\u3044\u3066\u306e\u89e3\u8aac\u304c\u8f09\u3063\u3066\u3044\u307e\u3057\u305f\u3002Django\u3001Pyramid\u3001Tornado\u3068\u3044\u3063\u305f\u3082\u306e\u3082\u6709\u540d\u3060\u305d\u3046\u3067\u3059\u3002\u3082\u3061\u308d\u3093\u57fa\u672c\u306fWSGI\uff08Web Server Gateway Interface\uff09\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u306b\u3064\u3044\u3066\u306f\u4ed6\u306e\u66f8\u7c4d\u3067\u7406\u89e3\u3057\u3066\u304a\u3044\u305f\u307b\u3046\u304c\u826f\u3044\u306e\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u74b0\u5883\u81ea\u52d5\u69cb\u7bc9\u306b\u3064\u3044\u3066\u306f\u3001Ansible\u304c\u7d39\u4ecb\u3055\u308c\u3066\u3044\u307e\u3059\u3002Chef\u306f\u66f8\u7c4d\u304c\u591a\u3044\u306e\u3067\u3059\u304c\u3001Ansible\u306f\u66f8\u7c4d\u306f\u307f\u304b\u3051\u307e\u305b\u3093\u3002\u4eba\u6c17\u306f\u306a\u3044\u306e\u304b\u3001\u7c21\u5358\u3060\u304b\u3089\u306a\u306e\u304b\u308f\u304b\u308a\u307e\u305b\u3093\u304c\u3001\u3061\u3087\u3046\u3069\u4f7f\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u305f\u306e\u3067\u52a9\u304b\u308a\u307e\u3059\u3002\u4eca\u5f8c\u306f\u74b0\u5883\u81ea\u52d5\u69cb\u7bc9\u306b\u3064\u3044\u3066\u3082\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306e\u89e3\u8aac\u672c\u306b\u8aac\u660e\u304c\u3055\u308c\u308b\u6642\u4ee3\u304c\u304f\u308b\u306e\u3067\u3057\u3087\u3046\u306d\u3002<\/p>\n<p>\u81ea\u5206\u306fUbuntu\u3092\u3088\u304f\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u81ea\u5206\u5411\u3051\u306b\u74b0\u5883\u69cb\u7bc9\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u81ea\u5206\u5411\u3051\u306e\u8a18\u9332\u3092\u516c\u958b\u3057\u3066\u304a\u304d\u307e\u3059\u3002Ansible\u3092\u4f7f\u3063\u305f\u74b0\u5883\u69cb\u7bc9\u306f\u5225\u9014\u691c\u8a0e\u3057\u3066\u307f\u308b\u4e88\u5b9a\u3067\u3059\u3002\u66f8\u7c4d\u306e\u5185\u5bb9\u3068\u306f\u5fae\u5999\u306b\u9055\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>Python, Python3\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><br \/>\nPython2\u3001Python3\u306e\u4e21\u65b9\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ sudo apt-get -y install python python3\r\n<\/pre>\n<p><strong>pip, virtualenv\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><br \/>\nPython\u74b0\u5883\u306fvirtualenv\u3092\u7d44\u307f\u5408\u308f\u305b\u308c\u3070\u3044\u3044\u306e\u3067\u3001Ubuntu\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u304b\u3089pip\u3068virtualenv\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ sudo apt-get -y install python-pip python3-pip\r\n$ sudo apt-get -y install python-virtualenv virtualenvwrapper\r\n<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001Ubuntu\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408\u306f\u3001pip\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ sudo pip install virtualenv\r\n$ sudo pip install virtualenvwrapper\r\n<\/pre>\n<p><strong>virtualenv\u306e\u4f7f\u3044\u65b9<\/strong><br \/>\n\u4f8b\u3048\u3070\u3001app001\u7528\u74b0\u5883\uff08app001_env\uff09\u306e\u7528\u610f\u3092\u3059\u308b\u306b\u306f\u4e0b\u8a18\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ mkdir -p ~\/workspace\/python\/\r\n$ cd ~\/workspace\/python\/\r\n$ virtualenv app001_env\r\n<\/pre>\n<p>app001_env\u74b0\u5883\u3092\u6709\u52b9\u5316\u3059\u308b\u306b\u306f\u4e0b\u8a18\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ source app001_env\/bin\/activate\r\n<\/pre>\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\u5909\u66f4\u306b\u306f\u3001&#8211;prompt\u3092\u6307\u5b9a\u3057\u3066\u74b0\u5883\u3092\u4f5c\u6210\u3002<\/p>\n<p>$ virtualenv &#8211;prompt app002 app002_env<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ source app002_env\/bin\/activate\r\napp002$\r\n<\/pre>\n<p>virtual\u74b0\u5883\u304b\u3089\u306c\u3051\u308b\u306b\u306fdeactivate\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\napp002$ deactivate\r\n<\/pre>\n<p>\u30b7\u30b9\u30c6\u30e0\u30b5\u30a4\u30c8\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u5229\u7528\u3059\u308b\u74b0\u5883\u3092\u7528\u610f\u3059\u308b\u5834\u5408\u306f\u3001&#8211;system-site-package\u3092\u6307\u5b9a\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ virtualenv --system-site-package app003_env\r\n<\/pre>\n<p>virtualenv\u74b0\u5883\u4e0b\u3067pip\u30b3\u30de\u30f3\u30c9\u3067Python\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\u3001\u305d\u306e\u74b0\u5883\u4e0b\u306b\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u308b\u305d\u3046\u3067\u3059\u3002\u3061\u3087\u3063\u3068\u8a66\u3057\u3066\u307f\u305f\u3044\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u3063\u305f\u308a\u3059\u308b\u3068\u304d\u306b\u4fbf\u5229\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n<p><strong>virtualenvwrapper\u306e\u5229\u7528<\/strong><br \/>\nvirtualenvwrapper\u3092\u4f7f\u3046\u306b\u306f ~\/.bashrc\u3078\u4e0b\u8a18\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u4e00\u5ea6\u30ed\u30b0\u30a2\u30a6\u30c8\u3057\u3066\u304b\u3089\u3001\u30ed\u30b0\u30a4\u30f3\u3057\u306a\u304a\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\nexport PROJECT_HOME=${HOME}\/workspace\/python\/ve\/projects\r\nexport WORKON_HOME=${HOME}\/workspace\/python\/ve\/workon\r\nsource \/usr\/share\/virtualenvwrapper\/virtualenvwrapper.sh\r\n# which\u3067\u30d1\u30b9\u304c\u308f\u304b\u308b\u306a\u3089\u4e0b\u8a18\u3067\u3082\u826f\u3044\r\n# source `which virtualenvwrapper.sh`\r\n<\/pre>\n<p>\u6307\u5b9a\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u4f5c\u6210\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ mkdir -p ~\/workspace\/python\/ve\/projects\r\n$ mkdir -p ~\/workspace\/python\/ve\/workon\r\n<\/pre>\n<p>virtualenv\u74b0\u5883\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u4e0b\u8a18\u3002\u3053\u308c\u3067\u3001${WORKON_HOME}\/app005_env\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ mkvirtualenv app005_env\r\n<\/pre>\n<p>\u6709\u52b9\u5316\u306b\u306fworkon\u30b3\u30de\u30f3\u30c9<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ workon app005_env\r\n<\/pre>\n<p>\u7121\u52b9\u5316\u306b\u306fdeactivate\u30b3\u30de\u30f3\u30c9<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\napp005_env$ deactivate\r\n<\/pre>\n<p>\u74b0\u5883\u306e\u79fb\u52d5\u306b\u306f\u4e0b\u8a18<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\napp005_env$ cdvirtualenv app006_env\r\n<\/pre>\n<p><strong>PyCharm\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><br \/>\n\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u308f\u304b\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ wget https:\/\/download.jetbrains.com\/python\/pycharm-community-4.0.6.tar.gz\r\n$ if [ ! -e $HOME\/app\/ ]; then; mkdir $HOME\/app; fi\r\n$ tar xf ~\/Download\/pycharm-community-4.0.6.tar.gz -C $HOME\/app\/\r\n<\/pre>\n<p>\u8d77\u52d5\u306f\u4e0b\u8a18\u3002<\/p>\n<pre class=\"brush: bash; gutter: true\">\r\n$ sh ~\/app\/pycharm-community-4.0.6\/bin\/pycharm.sh\r\n<\/pre>\n<p><iframe loading=\"lazy\" style=\"width: 120px; height: 240px;\" src=\"\/\/rcm-jp.amazon.co.jp\/e\/cm?t=hiro345-22&amp;o=9&amp;p=8&amp;l=as1&amp;asins=4774173207&amp;ref=tf_til&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr\" height=\"240\" width=\"320\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300cPython\u30a8\u30f3\u30b8\u30cb\u30a2\u990a\u6210\u8aad\u672c\uff3b\u3044\u307e\u3069\u304d\u306e\u958b\u767a\u30ce\u30a6\u30cf\u30a6\u6e80\u8f09\uff01\uff3d (Software Design plus) \u300d\u3092\u8aad\u307f\u306a\u304c\u3089\u30012015\u5e745\u6708\u7248 Python\u306e\u958b\u767a\u74b0\u5883\u3092Ubuntu\u306b\u69cb\u7bc9\u3092\u3057\u3066\u307f\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,6],"tags":[60,1189],"class_list":["post-17398","post","type-post","status-publish","format-standard","hentry","category-book","category-linux","tag-python","tag-virtualenv"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/17398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=17398"}],"version-history":[{"count":9,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/17398\/revisions"}],"predecessor-version":[{"id":17502,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/17398\/revisions\/17502"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=17398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=17398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=17398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}