[PYTHON] Pipenv Simply the main points

Why Pipenv?

You can do version control and package management at once.

Reasons to recommend

-Packages can be easily separated for each project. -You can easily separate python for each project. -If you specify a version of python that is not installed in pyenv, pyenv will be automatically executed and installed.

pip installation

pip

2 system


curl -kL https://bootstrap.pypa.io/get-pip.py | sudo python2

3 series


sudo apt-get install python3-distutils && curl -kL https://bootstrap.pypa.io/get-pip.py | sudo python3

pyenv installation

Installation of pyenv, etc.

pipenv installation

pipenv


sudo pip install pipenv

virtualenv-clone, virtualenv, pipenv will be installed in / usr / local / bin /. (Even if you run it in the local environment of pyenv, it will not be installed in ~ / .pyenv / shims /! (Of course)

If you install it, you can use it immediately without any settings.

Virtual environment

create

Move to the directory you want to create and execute the following
pipenv --python [Version specification]

Example) When a virtual environment is created in the test_pipenv directory ** [linux] ** ~ / .local / share / virtualenvs / test_pipenv-XxXxXxXx stores virtual environment data.

place

pipenv --venv

Enter the development environment

pipenv shell

Pip with it in

Update pip


pip install -U pip

By doing this, only pip in the development environment will be the latest version.

Location of the executable file installed with pip

Executable files such as juptyer and pip are in ~ / .local / share / virtualenvs / environment name / bin, but runtime in jupyter is in ~ / .local / share.

Manage packages in the development environment without entering

Not recommended as installation is slow


pipenv install pip

Get out of the development environment

exit

Delete development environment

pienv --rm

Run without entering the virtual environment

pipenv run python test.py
pipenv run pip show pip

Package management

Install the package by specifying the version

pipenv install package name==version
(Version is optional)

For development environment

pipenv install --dev package name

Pipfile

Make it the contents of Pipfile

 pipenv install 
pipenv install --dev

Make it the contents of Pipfile.lock

pipenv sync
pipenv sync --dev 

Update Pipfile

After update Pipfile.lock is updated


pipenv update

script

Setting

Pipfile


...
...
[scripts]
script = 'echo infinity'

Run

pipenv run script

Recommended Posts

Pipenv Simply the main points
pyenv Simply the main points
Make the tool simply
In the python command python points to python3.8
About the size of matplotlib points