LoginSignup
0
0

More than 1 year has passed since last update.

Python環境構築メモ

Last updated at Posted at 2021-10-14

環境構築

使うもの

  • pip (インストールに使う)
  • virtualenv (仮想環境構築に使う)

pipのインストール

以下をコマンドプロンプトにて実行。

python get-pip.py

pipと打ってコマンド一覧が出てきたらインストール済みってこと

virtualenvのインストール

以下をコマンドプロンプトにて実行

py -m pip install virtualenv

virtualenvと打ってコマンド一覧が出てきたらインストール済みってこと

virtualenv使い方

使い方の前に説明します。。。

virtualenvは実行環境(仮想環境)を作ることができるらしい
virtualenvの仮想環境とは:
異なるバージョンのpythonやフレームワークなどを各仮想環境へインストールすることができ、簡単に仮想環境を切り替えることによる簡易テストが可能となる場所を用意してくれます。

本題(使い方)

仮想環境の作成↓
py -m virtualenv <仮想環境名>
これをコマンドプロンプトに記述します。
今回はtrialという名前の仮想環境を作成します。

py -m virtualenv trial

上記コマンドを実行するとディレクトリ内に以下のようなファイルが生成されます
キャプチャ.PNG
ディレクトリの
PC > OS(C:) > Python > trial > Scripts
このtrialっていうファイルが仮想環境のフォルダーです。
仮想環境を起動する際はScriptsフォルダー内に存在する
・activate.bat
・deactivate.bat
をコマンドラインにて実行することで可能となります。

activate // 有効化するとき
deactivate // 無効化するとき

以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0