-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunix.html
More file actions
317 lines (295 loc) · 18.9 KB
/
Copy pathunix.html
File metadata and controls
317 lines (295 loc) · 18.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>2. Unix プラットフォームで Python を使う — Python 3.6.5 ドキュメント</title>
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '3.6.5',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/translations.js"></script>
<script type="text/javascript" src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Python 3.6.5 ドキュメント 内を検索"
href="../_static/opensearch.xml"/>
<link rel="author" title="このドキュメントについて" href="../about.html" />
<link rel="index" title="索引" href="../genindex.html" />
<link rel="search" title="検索" href="../search.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="next" title="3. Windows で Python を使う" href="windows.html" />
<link rel="prev" title="1. コマンドラインと環境" href="cmdline.html" />
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
<link rel="canonical" href="https://docs.python.jp/3/using/unix.html" /><script type="text/javascript">
$(document).ready(function() {
var base = 'https://docs.python.org/3.6/using/unix.html';
$('a.headerlink').each(function() {
var html = '<a href="' + base + $(this).attr('href') +
'" title="原文へのリンク"><small>(原文)</small></a>';
$(this).after(html);
})
});
</script>
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/version_switch.js"></script>
</head>
<body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>ナビゲーション</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="総索引"
accesskey="I">索引</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Pythonモジュール索引"
>モジュール</a> |</li>
<li class="right" >
<a href="windows.html" title="3. Windows で Python を使う"
accesskey="N">次へ</a> |</li>
<li class="right" >
<a href="cmdline.html" title="1. コマンドラインと環境"
accesskey="P">前へ</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li>
<span class="version_switcher_placeholder">3.6.5</span>
<a href="../index.html">ドキュメント</a> »
</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python のセットアップと利用</a> »</li>
<li class="right">
<div class="inline-search" style="display: none" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('.inline-search').show(0);</script>
|
</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="using-python-on-unix-platforms">
<span id="using-on-unix"></span><h1>2. Unix プラットフォームで Python を使う<a class="headerlink" href="#using-python-on-unix-platforms" title="このヘッドラインへのパーマリンク">¶</a></h1>
<div class="section" id="getting-and-installing-the-latest-version-of-python">
<h2>2.1. 最新バージョンの Python の取得とインストール<a class="headerlink" href="#getting-and-installing-the-latest-version-of-python" title="このヘッドラインへのパーマリンク">¶</a></h2>
<div class="section" id="on-linux">
<h3>2.1.1. Linux<a class="headerlink" href="#on-linux" title="このヘッドラインへのパーマリンク">¶</a></h3>
<p>ほとんどの Linux ディストリビューションでは Python はプリインストールされており、それ以外でもパッケージとして利用可能です。しかし、ディストリビューションのパッケージでは利用したい機能が使えない場合があります。最新版の Python をソースから簡単にコンパイルすることができます。</p>
<p>Python がプリインストールされておらず、リポジトリにも無い場合、ディストリビューション用のパッケージを簡単につくることができます。以下のリンクを参照してください:</p>
<div class="admonition seealso">
<p class="first admonition-title">参考</p>
<dl class="last docutils">
<dt><a class="reference external" href="https://www.debian.org/doc/manuals/maint-guide/first.en.html">https://www.debian.org/doc/manuals/maint-guide/first.en.html</a></dt>
<dd>Debian ユーザー向け</dd>
<dt><a class="reference external" href="https://en.opensuse.org/Portal:Packaging">https://en.opensuse.org/Portal:Packaging</a></dt>
<dd>OpenSuse ユーザー向け</dd>
<dt><a class="reference external" href="https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html">https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-creating-rpms.html</a></dt>
<dd>Fedora ユーザー向け</dd>
<dt><a class="reference external" href="http://www.slackbook.org/html/package-management-making-packages.html">http://www.slackbook.org/html/package-management-making-packages.html</a></dt>
<dd>Slackware ユーザー向け</dd>
</dl>
</div>
</div>
<div class="section" id="on-freebsd-and-openbsd">
<h3>2.1.2. FreeBSD と OpenBSD<a class="headerlink" href="#on-freebsd-and-openbsd" title="このヘッドラインへのパーマリンク">¶</a></h3>
<ul>
<li><p class="first">FreeBSD ユーザーが Python パッケージを追加するには次のようにしてください:</p>
<div class="highlight-sh"><div class="highlight"><pre><span></span>pkg install python3
</pre></div>
</div>
</li>
<li><p class="first">OpenBSD users, to add the package use:</p>
<div class="highlight-sh"><div class="highlight"><pre><span></span>pkg_add -r python
pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/<insert your architecture here>/python-<version>.tgz
</pre></div>
</div>
<p>例えば、i386 ユーザーが Python 2.5.1 を取得するには次のようにします:</p>
<div class="highlight-sh"><div class="highlight"><pre><span></span>pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2.tgz
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="on-opensolaris">
<h3>2.1.3. OpenSolaris<a class="headerlink" href="#on-opensolaris" title="このヘッドラインへのパーマリンク">¶</a></h3>
<p><a class="reference external" href="https://www.opencsw.org/">OpenCSW</a> から Python を入手することができます。 Python の様々なバージョンが利用可能でインストールすることができます。e.g. <code class="docutils literal"><span class="pre">pkgutil</span> <span class="pre">-i</span> <span class="pre">python27</span></code>.</p>
</div>
</div>
<div class="section" id="building-python">
<span id="building-python-on-unix"></span><h2>2.2. Python のビルド<a class="headerlink" href="#building-python" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>If you want to compile CPython yourself, first thing you should do is get the
<a class="reference external" href="https://www.python.org/downloads/source/">source</a>. You can download either the
latest release’s source or just grab a fresh <a class="reference external" href="https://devguide.python.org/setup/#getting-the-source-code">clone</a>. (If you want
to contribute patches, you will need a clone.)</p>
<p>ビルドは通常次の手順で行います</p>
<div class="highlight-sh"><div class="highlight"><pre><span></span>./configure
make
make install
</pre></div>
</div>
<p>Configure のオプションや特定の Unix プラットフォームにおける注意点は Python ソースツリーのルートにある <a class="reference external" href="https://github.com/python/cpython/tree/3.6/README.rst">README.rst</a> に細かく記載されています。</p>
<div class="admonition warning">
<p class="first admonition-title">警告</p>
<p class="last"><code class="docutils literal"><span class="pre">make</span> <span class="pre">install</span></code> は <code class="file docutils literal"><span class="pre">python3</span></code> バイナリを上書きまたはリンクを破壊してしまうかもしれません。そのため、<code class="docutils literal"><span class="pre">make</span> <span class="pre">install</span></code> の代わりに <code class="file docutils literal"><em><span class="pre">exec_prefix</span></em><span class="pre">/bin/python</span><em><span class="pre">version</span></em></code> のみインストールする <code class="docutils literal"><span class="pre">make</span> <span class="pre">altinstall</span></code> が推奨されています。</p>
</div>
</div>
<div class="section" id="python-related-paths-and-files">
<h2>2.3. Python に関係するパスとファイル<a class="headerlink" href="#python-related-paths-and-files" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>これらはローカルインストールの慣例に応じて変化します; <span class="target" id="index-6"></span><code class="xref std std-envvar docutils literal"><span class="pre">prefix</span></code> (<code class="docutils literal"><span class="pre">${prefix}</span></code>) と <span class="target" id="index-7"></span><code class="xref std std-envvar docutils literal"><span class="pre">exec_prefix</span></code> (<code class="docutils literal"><span class="pre">${exec_prefix}</span></code>) はインストール状況に依存していて、GNU ソフトウェアによって解釈されます; この二つは同じである場合があります。</p>
<p>例えば、ほとんどの Linux システムでは、両方のデフォルトが <code class="file docutils literal"><span class="pre">/usr</span></code> です。</p>
<table border="1" class="docutils">
<colgroup>
<col width="53%" />
<col width="47%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">ファイル/ディレクトリ</th>
<th class="head">意味</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="file docutils literal"><em><span class="pre">exec_prefix</span></em><span class="pre">/bin/python3</span></code></td>
<td>インタプリタの推奨される場所</td>
</tr>
<tr class="row-odd"><td><code class="file docutils literal"><em><span class="pre">prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></code>,
<code class="file docutils literal"><em><span class="pre">exec_prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></code></td>
<td>標準モジュールを格納するディレクトリの、推奨される場所。</td>
</tr>
<tr class="row-even"><td><code class="file docutils literal"><em><span class="pre">prefix</span></em><span class="pre">/include/python</span><em><span class="pre">version</span></em></code>,
<code class="file docutils literal"><em><span class="pre">exec_prefix</span></em><span class="pre">/include/python</span><em><span class="pre">version</span></em></code></td>
<td>Python 拡張や Python の埋込みに必要となる include ファイルを格納するディレクトリの推奨される場所。</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="miscellaneous">
<h2>2.4. その他<a class="headerlink" href="#miscellaneous" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>To easily use Python scripts on Unix, you need to make them executable,
e.g. with</p>
<div class="highlight-shell-session"><div class="highlight"><pre><span></span><span class="gp">$</span> chmod +x script
</pre></div>
</div>
<p>適切な shebang 行をスクリプトの先頭に置きます。たいていの場合良い方法は</p>
<div class="highlight-sh"><div class="highlight"><pre><span></span><span class="ch">#!/usr/bin/env python3</span>
</pre></div>
</div>
<p>で、<span class="target" id="index-8"></span><code class="xref std std-envvar docutils literal"><span class="pre">PATH</span></code> 全体から Python インタープリターを探します。しかし、いくつかの Unix は <strong class="program">env</strong> コマンドを持たないので、インタープリターのパスを <code class="docutils literal"><span class="pre">/usr/bin/python3</span></code> のようにハードコードしなければならないかもしれません。</p>
<p>シェルコマンドを Python スクリプトから使うには、 <a class="reference internal" href="../library/subprocess.html#module-subprocess" title="subprocess: Subprocess management."><code class="xref py py-mod docutils literal"><span class="pre">subprocess</span></code></a> モジュールを参照してください。</p>
</div>
<div class="section" id="editors-and-ides">
<h2>2.5. エディタと IDE<a class="headerlink" href="#editors-and-ides" title="このヘッドラインへのパーマリンク">¶</a></h2>
<p>Python プログラミング言語をサポートする IDE はたくさんあります。
多くのエディタや IDE にはシンタックスハイライト機能、デバッグツール、 PEP-8 チェック機能があります。</p>
<p>包括的な一覧を見るには、 <a class="reference external" href="https://wiki.python.org/moin/PythonEditors">Python Editors</a> や <a class="reference external" href="https://wiki.python.org/moin/IntegratedDevelopmentEnvironments">Integrated Development Environments</a> を訪れてください。</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../contents.html">目次</a></h3>
<ul>
<li><a class="reference internal" href="#">2. Unix プラットフォームで Python を使う</a><ul>
<li><a class="reference internal" href="#getting-and-installing-the-latest-version-of-python">2.1. 最新バージョンの Python の取得とインストール</a><ul>
<li><a class="reference internal" href="#on-linux">2.1.1. Linux</a></li>
<li><a class="reference internal" href="#on-freebsd-and-openbsd">2.1.2. FreeBSD と OpenBSD</a></li>
<li><a class="reference internal" href="#on-opensolaris">2.1.3. OpenSolaris</a></li>
</ul>
</li>
<li><a class="reference internal" href="#building-python">2.2. Python のビルド</a></li>
<li><a class="reference internal" href="#python-related-paths-and-files">2.3. Python に関係するパスとファイル</a></li>
<li><a class="reference internal" href="#miscellaneous">2.4. その他</a></li>
<li><a class="reference internal" href="#editors-and-ides">2.5. エディタと IDE</a></li>
</ul>
</li>
</ul>
<h4>前のトピックへ</h4>
<p class="topless"><a href="cmdline.html"
title="前の章へ">1. コマンドラインと環境</a></p>
<h4>次のトピックへ</h4>
<p class="topless"><a href="windows.html"
title="次の章へ">3. Windows で Python を使う</a></p>
<div role="note" aria-label="source link">
<h3>このページ</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">バグ報告</a></li>
<li>
<a href="https://github.com/python/cpython/blob/3.6/Doc/using/unix.rst"
rel="nofollow">ソースの表示
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>ナビゲーション</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="総索引"
>索引</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Pythonモジュール索引"
>モジュール</a> |</li>
<li class="right" >
<a href="windows.html" title="3. Windows で Python を使う"
>次へ</a> |</li>
<li class="right" >
<a href="cmdline.html" title="1. コマンドラインと環境"
>前へ</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li>
<span class="version_switcher_placeholder">3.6.5</span>
<a href="../index.html">ドキュメント</a> »
</li>
<li class="nav-item nav-item-1"><a href="index.html" >Python のセットアップと利用</a> »</li>
<li class="right">
<div class="inline-search" style="display: none" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('.inline-search').show(0);</script>
|
</li>
</ul>
</div>
<div class="footer">
© <a href="../copyright.html">Copyright</a> 2001-2018, Python Software Foundation.
<br />
Python Software Foundation は非営利団体です。
<a href="https://www.python.org/psf/donations/">寄付</a>
<br />
最終更新日時: 7月 29, 2018
<a href="../bugs.html">バグを見つけたら</a>?
<br />
このドキュメントは <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.6.5 を使って作成されました。
</div>
</body>
</html>