LoginSignup
1
1

More than 1 year has passed since last update.

Ubuntu22.04 Python仮想環境にDjangoとDjango REST frameworkをインストールする

Last updated at Posted at 2022-08-04

概要

UbuntuのPython仮想環境にDjangoとDjango REST framework(DRF)をインストールします。仮想環境はDjango推奨のvenv、環境はUbuntu22.04、Python3.10.6、Django3.2.15(LTS)、DRF 3.13.1です。

2022/8/10現在Djangoは3.2系の最新は3.2.15、Django REST frameworkの最新は3.13.1でした。

$ python3 -m pip install Django==

image.png

$ python3 -m pip install djangorestframework==

image.png

手順1 仮想環境を作る

ユーザのホームにフォルダを作ってその中に仮想環境を作ります。

$ mkdir solution
$ cd solution
solution$ python3 -m venv .venv_drf

手順2 仮想環境をアクティブにしてpipを最新版にする

仮想環境でpipを最新にします。

solution$ source .venv_drf/bin/activate
(.venv_drf) solution$ python -m pip install --upgrade pip

手順3 Django3.2の最新版とDRFの最新版をインストールする

(.venv_drf) solution$ python -m pip install Django==3.2.*
(.venv_drf) solution$ python -m pip install djangorestframework

仮想環境を閉じます。

(.venv_drf) solution$ deactivate
solution$ 

さいごに

今回は開発環境ですが、本番環境でも仮想環境を使えば他のwebアプリとライブラリを別にできるので、拡張性を考えて仮想環境を作ろうと思います。

1
1
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
1
1