[PYTHON] Pipenv usage summary (for myself)

Introduction

It's okay to see the details by looking at other people's articles, but I thought that there are few things that can be understood in one article as to what can be done during development. I tried to summarize that it is not enough for everyone to understand, but that it is enough for me.

environment

Introduction

Until Pipenv is installed Look at this

How to use

Initialization

For Python 3 series

$ pipenv --python 3

Package installation

$ pipenv install django
$ pipenv install numpy==1.17.4  #Specify the version

Pipfile


[packages]
django = "*"
numpy = "1.17.4"

When installing the development package

$ pipenv install --dev flake8

Pipfile


[dev-packages]
flake8 = "*"

Building the environment

I'll do a bundle install ~

$ pipenv install
$ pipenv install --dev #For development

When you want to reproduce the environment from Pipfile.lock

$ pipenv sync

Version upgrade of installed packages

$ pipenv update

script

Edit Pipfile by yourself and write as below.

Pipfile


[scripts]
main = "python main.py"

Run scripts

$ pipenv run main

In addition, it can be executed individually without entering the virtual environment.


$ pipenv run python main.py

Virtual environment

Do you want to create .venv under the project directory? ?? ?? So

.bashrc


export PIPENV_VENV_IN_PROJECT=true

After that how to use

$ pipenv shell   #Virtual environment
$ exit           #Exit
$ pipenv --venv  #Virtual environment path
$ pipenv --rm    #Delete virtual environment

Summary

I think there are people who write more properly, but I have summarized the ones I use for the time being.

To be honest, I've just started Python, so I just researched and summarized it, and I wrote it appropriately, so please think about it like this.

Seriously, you should read and understand the ones you know (oversized boomerang).

It's a little off topic, but isn't it a stable version of WSL2 soon? Use docker ~~

Recommended Posts

Pipenv usage summary (for myself)
pytest usage summary
Summary of frequently used Python arrays (for myself)
Summary of pyenv usage
heroku memo (for myself)
Summary for learning RAPIDS
Freecad memorandum (for myself)
Summary of python environment settings for myself [mac] [ubuntu]
pandas Matplotlib Summary by usage
Python memo (for myself): Array
Python Tkinter notes (for myself)
Convenient usage summary of Flask
Basic usage of Pandas Summary
Linux Command Dictionary (for myself)
Reference resource summary (for beginners)
[Note] [For myself] Django command
Sentence summary using BERT [for relatives]
What is scraping? [Summary for beginners]
(For myself) Flask_7 (Open database from Flask)
Raspberry pi initial setting (for myself)
Binary search summary for competition professionals
(For myself) Flask_ex (templates and static)
Pandas basics summary link for beginners
[For competition professionals] Run-length compression summary
[For competition professionals] Summary of doubling