It seems good to combine
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)
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.
# 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
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
# create requirements.txt, at current directory $ pipreqs . # install packages listed in requirements.txt $ pip install -r requirements.txt