-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tutorial of create virtual environment
- Loading branch information
1 parent
b725bb7
commit 5d4379a
Showing
19 changed files
with
212 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,7 +350,7 @@ Python言語ユーザー向け | |
except KeyboardInterrupt: | ||
destroy() | ||
**コードの説明*** | ||
**コードの説明** | ||
|
||
.. code-block:: python | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ | |
:maxdepth: 2 | ||
|
||
i2c_configuration | ||
spi_configuration | ||
spi_configuration | ||
create_virtual_environment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
.. _create_virtual: | ||
|
||
仮想環境の作成 | ||
====================================== | ||
Raspberry Piや類似のデバイスを使用する場合、 ``pip`` を仮想環境でパッケージをインストールすることをお勧めします。これにより、依存関係の分離、システムのセキュリティの向上、システムのクリーンさの維持、プロジェクトの移行と共有の容易化が行われ、依存関係の管理が簡素化されます。これらの利点により、仮想環境はPython開発において非常に重要で便利なツールとなっています。 | ||
|
||
以下に、仮想環境を作成する手順を示します。 | ||
|
||
**1. 仮想環境の作成** | ||
|
||
まず、システムにPythonがインストールされていることを確認する必要があります。Pythonバージョン3.3以降では、仮想環境を作成するための ``venv`` モジュールが付属しており、別途インストールする必要はありません。Python 2またはPython 3.3以前のバージョンを使用している場合は、 ``virtualenv`` をインストールする必要があります。 | ||
|
||
* Python 3の場合: | ||
|
||
Python 3.3以降のバージョンでは、 ``venv`` モジュールを直接使用できます: | ||
|
||
.. raw:: html | ||
|
||
<run></run> | ||
|
||
.. code-block:: shell | ||
python3 -m venv myenv | ||
これにより、現在のディレクトリに名前が ``myenv`` の仮想環境が作成されます。 | ||
|
||
* Python 2の場合: | ||
|
||
まだPython 2を使用している場合は、まず ``virtualenv`` をインストールする必要があります: | ||
|
||
.. raw:: html | ||
|
||
<run></run> | ||
|
||
.. code-block:: shell | ||
pip install virtualenv | ||
次に、仮想環境を作成します: | ||
|
||
.. raw:: html | ||
|
||
<run></run> | ||
|
||
.. code-block:: shell | ||
virtualenv myenv | ||
これにより、現在のディレクトリに名前が ``myenv`` の仮想環境が作成されます。 | ||
|
||
**2. 仮想環境の有効化** | ||
|
||
仮想環境を作成した後、使用するためにそれを有効化する必要があります。 | ||
|
||
.. note:: | ||
|
||
Raspberry Piを再起動するたびや、新しいターミナルを開くたびに、仮想環境を有効化するために次のコマンドを再度実行する必要があります。 | ||
|
||
.. raw:: html | ||
|
||
<run></run> | ||
|
||
.. code-block:: shell | ||
source myenv/bin/activate | ||
仮想環境が有効化されると、コマンドラインのプロンプトの前に環境名が表示され、仮想環境内で作業していることが示されます。 | ||
|
||
**3. 依存関係のインストール** | ||
|
||
仮想環境を有効化した状態で、pipを使用して必要な依存関係をインストールできます。例: | ||
|
||
.. raw:: html | ||
|
||
<run></run> | ||
|
||
.. code-block:: shell | ||
pip install requests | ||
これにより、requestsライブラリがグローバル環境ではなく、現在の仮想環境にインストールされます。このステップは1度だけ行えば十分です。 | ||
|
||
**4. 仮想環境の終了** | ||
|
||
作業を完了し、仮想環境から退出したい場合は、単純に次のコマンドを実行します: | ||
|
||
.. raw:: html | ||
|
||
<run></run> | ||
|
||
.. code-block:: shell | ||
deactivate | ||
これにより、システムのグローバルPython環境に戻ります。 | ||
|
||
**5. 仮想環境の削除** | ||
|
||
特定の仮想環境をもはや必要としない場合は、単純にその仮想環境を含むディレクトリを削除できます: | ||
|
||
.. raw:: html | ||
|
||
<run></run> | ||
|
||
.. code-block:: shell | ||
rm -rf myenv | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.