LoginSignup
4
2

More than 1 year has passed since last update.

Pyflow使ってDjangoが使える環境を作る

Last updated at Posted at 2021-07-15

はじめに

Pyflowを使いながらDjango環境構築方法が探してもなかったので、どうやってやったのかここにメモします。

Pyflowとは

引用
Pyflow はおそらく一番新参のパッケージ管理ツールです。Rust で書かれており、Poetry で導入された PEP 518 に加え、PEP 582 で提案された、プロジェクト内で扱える仮想環境を複数の Python バージョンに対応させることができます。Pyenv + venv で 1 つの Python のパージョンの 1 つの仮想環境を扱う Pipenv/Poetry に対して、Pyflow は単体で Python のバージョンを複数管理して任意のバージョンで仮想環境を作ることができます。現環境で大きな恩恵は無い気もしますが、今後 Python にメジャーアップデートがあった場合などに重宝されるかもしれません。個人的な懸念は Rust で書かれていることで、速度等で恩恵がありそうな一方で、Rust にある程度の理解がないとエラーメッセージに対応しづらい点と、開発コミュニティが伸びにくいということです。
@sk217さん - 2020 年の Python パッケージ管理ベストプラクティス

Pyflowのインストール

$ brew install pyflow

PyflowでProjectを作成

$ pyflow new プロジェクト名

プロジェクト作成手順

$ pyflow new sample

#使いたいPythonのバージョン書いてください
Please enter the Python version for this project: (eg: 3.8)
Default [2.7.16]: 3.9
Created a new Python project named sample

Djangoをインストール

# 作ったプロジェクトファイルに移動
$ cd プロジェクト名
# Djangoをインストール
$ pyflow install django

 インストール手順

HEKUTA sample % pyflow install django
Found multiple compatible Python versions. Please enter the number associated with the one you'd like to use:
1: python3.9: 3.9.6
2: python3: 3.9.6
1
🐍 Setting up Python...
⬇ Installing pytz 2017.2 ...
⬇ Installing django 3.2.5 ...
Added a console script: django-admin
⬇ Installing sqlparse 0.4.1 ...
Added a console script: sqlformat
⬇ Installing asgiref 3.4.1 ...
Installation complete

なぞのエラー

わかる方がいれば教えてください
これが出たりするんですが、一様djangoは動きました。細かいこと試してないので、心配な方はファイルを消して、最初からやり直してみてください

HEKUTA sample % pyflow install django
Found multiple compatible Python versions. Please enter the number associated with the one you'd like to use:
1: python3.9: 3.9.6
2: python3: 3.9.6
2
.... 省略
        ],
        extra: None,
        sys_platform: None,
        python_version: None,
        install_with_extras: None,
        path: None,
        git: None,
    },
]
             It's taking a long time to get dependency data - this usually suggests that the dependency tree is being newly built. Please try again in a few minutes, and if the error still occurs, consider opening an issue on github.
HEKUTA sample % 

パッケージのビルド

インストールが終わったらパッケージをビルドします

$ pyflow package

Djangoの起動

djangoのプロジェクトを作ってください。

プロジェクト名/プロジェクト名/djangoprojectの中に作りました。
プロジェクト名/djangoprojectていう感じでも動いたんですけど、どっちが正解かわからないので、私はプロジェクト名/プロジェクト名/djangoprojectにしました

起動!

$ cd djangoproject
$ pyflow manage.py runserver

参考にした記事

4
2
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
4
2