virtual environment in python

Overview

It seems good to combine pyenv and pipenv.

Developed with pyenv and pipenv

$pyenv versions (python version check)
$pyenv install 3.7.0 (install the version signified in the project)
$pyenv local 3.7.0 (set and fix python version in the project)
$pip install pipenv (if pipenv is not installed yet)
$pipenv --python 3.7.0 (create virtual env with python 3.7.0)
$pipenv shell (go into the virtual env)
$pipenv install some_package (even in the virtual env shell, use pipenv install, not pip install)
#Developed here
$exit (go out of virtual env)

Caution

After you pip install some packages in the project, notify that to other members who are working on other branches. This avoids the conflict of package versions when these branches are merged.

Each is explained in detail below.

Details of Pipenv

# If you are the person who makes Pipfiles,,,  in the project root dir, launch python venv. This creates Pipfile and Pipfile.lock.
$pipenv --python 3.6
# If you would like to set up venv from Pipfiles made by another person, create venv and then install packages wirtten in Pipfiles
$pipenv install --deploy
(NOTE: --deploy causes build-fail when package has not been synced)
# Other commands
$pipenv import pandas==3.5  =  $pipenv run pip install pandas==3.5
# Import python package into venv
$pipenv --python
# Import python package (which is not used in src) into venv
$pipenv install --dev flake8
# terminate venv by deleting ve
pip env --rm 
# Go into the venv
$pipenv shell
# Go out of the venv
$exit

Details of virtualenv

First, specify the python version with pyenv, and then build the virtualenv environment (named test). After finishing, delete the test directory.

$ cd ~/path_to/lambda_data_agg
$ pyenv local 3.6.0
$ virtualenv test
$ source test/bin/activate
$ pip install -r requirements.txt
#work
$ deactive
$ rm -rf test

How to create / use requirements.txt

# create requirements.txt, at current directory
$ pipreqs .

# install packages listed in requirements.txt
$ pip install -r requirements.txt

Recommended Posts

virtual environment in python
Development environment in Python
Virtual environment with Python 3.6
Ubuntu18.04.05 Creating a python virtual environment in LTS
Create a virtual environment with conda in Python
Handle environment variables in Python
Building a Python virtual environment
Work in a virtual environment with Python virtualenv.
Use jupyter-lab installed in python virtual environment (venv)
venv: Python virtual environment management
python standard virtual environment venv
Building a Python virtual environment
Build python virtual environment with virtualenv
[Personal memo] Python virtual environment command memo
Install scrapy in python anaconda environment
Create a virtual environment with Python!
Building a virtual environment with Python 3
install tensorflow in anaconda + python3.5 environment
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Python environment construction
python environment settings
Unittest in python
python windows environment
[Django3] Display a web page in Django3 + WSL + Python virtual environment
Environment construction (python)
Epoch in Python
Discord in Python
Beginner virtual environment
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
How to develop in a virtual environment of Python [Memo]
Plink in Python
Constant in python
python environment construction
Python --Environment construction
After enabling the python virtual environment in the batch file, run the python file
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
Python environment construction
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv