{"id":1623,"date":"2018-03-12T22:43:14","date_gmt":"2018-03-12T13:43:14","guid":{"rendered":"http:\/\/www.python.ambitious-engineer.com\/?p=1623"},"modified":"2018-11-04T15:33:52","modified_gmt":"2018-11-04T06:33:52","slug":"venv%e3%81%ab%e3%82%88%e3%82%8b%e4%bb%ae%e6%83%b3%e7%92%b0%e5%a2%83%e4%bd%9c%e6%88%90","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/1623","title":{"rendered":"venv\u306b\u3088\u308b\u4eee\u60f3\u74b0\u5883\u4f5c\u6210"},"content":{"rendered":"<h2>Python\u306e\u4eee\u60f3\u74b0\u5883\u3068\u306f<\/h2>\n<p>Python\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3059\u308b\u969b\u3001pip\u306a\u3069\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4e00\u3064\u306e\u74b0\u5883\u3067\u5225\u306ePython\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u4ee5\u524d\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u4e0d\u8981\u306b\u306a\u3063\u305f\u308a\u7570\u306a\u308b\u7af6\u5408\u3057\u305f\u308a\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3046\u3044\u3063\u305f\u3053\u3068\u3092\u907f\u3051\u308b\u305f\u3081\u3001\u901a\u5e38\u3001Python\u306b\u9650\u3089\u305a\u30d7\u30ed\u30b0\u30e9\u30e0\u3084\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3054\u3068\u306b\u4eee\u60f3\u7684\u306a\u74b0\u5883\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u8fd1\u5e74\u4e00\u822c\u7684\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070A\u3068B\u3068\uff12\u3064\u306e\u4eee\u60f3\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u305f\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eee\u60f3\u74b0\u5883A\u3067\u306f\u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u3001\u4eee\u60f3\u74b0\u5883B\u3067\u306f\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u5225\u3005\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u65b0\u305f\u306b\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u4f5c\u6210\u3059\u308b\u5ea6\u306b\u65b0\u305f\u306b\u74b0\u5883\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u3046\u3044\u3063\u305f\u4eee\u60f3\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b\u305f\u3081\u306b\u3001Unix\u7cfb\u30e6\u30fc\u30b6\u30fc\u306fpyenv + virtualenv\u304c\u4f7f\u3048\u307e\u3059\u304c\u3001\u305d\u308c\u4ee5\u5916\u306b\u3082Python3\u306b\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067venv\u3068\u3044\u3046\u4eee\u60f3\u74b0\u5883\u4f5c\u6210\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u5229\u7528\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>Python3\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u4ed8\u5c5e\u3057\u3066\u3044\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3059\u306e\u3067\u3001Windows\u30e6\u30fc\u30b6\u30fc\u3067\u3082\u5229\u7528\u53ef\u80fd\u3067\u3059\u3002\uff08\u305f\u3060\u3057\u3001pyenv\u306e\u3088\u3046\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u6bce\u306b\u74b0\u5883\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u306e\u3067\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff09<\/p>\n<h2>venv\u306b\u3088\u308b\u4eee\u60f3\u74b0\u5883\u306e\u4f5c\u6210<\/h2>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u4eee\u60f3\u74b0\u5883\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\npython -m venv \u74b0\u5883\u69cb\u7bc9\u5148\u306e\u30d1\u30b9\r\n<\/pre>\n<p>\u4ee5\u4e0b\u3001Windows\u30e6\u30fc\u30b6\u30fc\u5411\u3051\u306b\u69cb\u7bc9\u306e\u4e00\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u8d77\u52d5\u3057\u3066c:\\work\\pywork\\envs\u306bprojectA\u3001projectB\u3068\u3044\u30462\u3064\u306e\u74b0\u5883\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd c:\\work\\pywork\\envs\r\npython -m venv projectA\r\npython -m venv projectB\r\n<\/pre>\n<p>c:\\work\\pywork\\envs\u914d\u4e0b\u306b2\u3064\u30d5\u30a9\u30eb\u30c0\u304c\u4f5c\u6210\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u308c\u3067\u4eee\u60f3\u74b0\u5883\u306e\u5229\u7528\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2>\u4eee\u60f3\u74b0\u5883\u306e\u5207\u308a\u66ff\u3048<\/h2>\n<h3>activate.bat \u4eee\u60f3\u74b0\u5883\u306e\u8d77\u52d5<\/h3>\n<p>\u4eee\u60f3\u74b0\u5883projectA\u3092\u5229\u7528\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u4e0a\u3067\u4ee5\u4e0b\u306e\u30d0\u30c3\u30c1\u3092\u5b9f\u884c\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&gt; projectA\\Scripts\\activate.bat\r\n(projectA) &gt; \r\n<\/pre>\n<p>\u3053\u308c\u3067\u4eee\u60f3\u74b0\u5883projectA\u3092\u8d77\u52d5\u3057\u305f\u72b6\u614b\u306b\u306a\u308a\u307e\u3059\u3002\u5148\u7a0b\u306e\u7d9a\u304d\u3067pip\u3067\u9069\u5f53\u306a\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n(projectA)&gt; pip install flask\r\n(projectA)&gt; pip freeze\r\nclick==6.7\r\nFlask==0.12.2\r\nitsdangerous==0.24\r\nJinja2==2.10\r\nMarkupSafe==1.0\r\nWerkzeug==0.14.1\r\n<\/pre>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>deactivate.bat \u4eee\u60f3\u74b0\u5883\u304b\u3089\u629c\u3051\u308b<\/h3>\n<p>\u4eee\u60f3\u74b0\u5883\u3092\u629c\u3051\u308b\u5834\u5408\u3001deactivate.bat\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u5148\u7a0b\u306e\u7d9a\u304d\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n(projectA)&gt; projectA\\Scripts\\deactivate.bat\r\n&gt; \r\n<\/pre>\n<p>\u30d7\u30ed\u30f3\u30d7\u30c8\u306e\u6587\u5b57\u5217\u304c\u5909\u308f\u308a\u307e\u3057\u305f\u3002\u6b21\u306b\u3001\u4eee\u60f3\u74b0\u5883projectB\u306b\u5207\u308a\u66ff\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&gt; projectB\\Scripts\\activate.bat\r\n(projectB) &gt; pip freeze\r\n\r\n<\/pre>\n<p>pip freeze\u3067\u4eee\u60f3\u74b0\u5883projectB\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u78ba\u8a8d\u3057\u3066\u3082\u3001\u4f55\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u306a\u3044\u304d\u308c\u3044\u306a\u74b0\u5883\u3067\u3042\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001venv\u3092\u5229\u7528\u3059\u308b\u3068Windows\u3067\u3082\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u6bce\u306b\u4eee\u60f3\u74b0\u5883\u3092\u7c21\u5358\u306b\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>Unix\u7cfb\u306e\u5834\u5408<\/h2>\n<p>\u4e0a\u306e\u8aac\u660e\u306fWindows\u5411\u3051\u3067\u3059\u304c\u3001Unix\u7cfb\u3067\u3082\u540c\u69d8\u306b\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002bash\u3084zsh\u306e\u5834\u5408\u3001\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u306e\u4ee3\u308f\u308a\u306b \u4eee\u60f3\u74b0\u5883\u30d1\u30b9\/bin\/activate\u3092source\u3067\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002deactivate\u306b\u3064\u3044\u3066\u3082\u540c\u69d8\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u306e\u4eee\u60f3\u74b0\u5883\u3068\u306f Python\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3059\u308b\u969b\u3001pip\u306a\u3069\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4e00\u3064\u306e\u74b0\u5883\u3067\u5225\u306ePython\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u4ee5\u524d\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb...<\/p>\n","protected":false},"author":1,"featured_media":1878,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[39],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1623"}],"collection":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/comments?post=1623"}],"version-history":[{"count":6,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1623\/revisions"}],"predecessor-version":[{"id":1961,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/1623\/revisions\/1961"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/1878"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=1623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=1623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=1623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}