If your project depends on Python package versions and their dependencies, pipenv is for you. Pipenv creates a Pipfile.lock file, which you can use when you move to a different system. The Pipfile.lock file contains all the dependencies and their versions.
When you install Python packages using pipfile.lock, it will create exactly the same environment as your original system.
$ pip install pipenv
$ pipenv --python 3.7 install = creates pipenv and pipfile.lock as a virtual environment with python 3.7
Clone / create project repository:
$ cd myproject
Install from Pipfile, if there is one:
$ pipenv install
Or, add a package to your new project:
$ pipenv install <package>
This will create a Pipfile if one doesn’t exist. If one does exist, it will automatically be edited with the new package your provided.
Next, activate the Pipenv shell:
$ pipenv shell
$ python --version
Once you install a package, you can find the package and hashes under default in the pipfile.lock. This will secure an identical environment in a different system. You'll have to use pipenv to install packages rather than pip.
List all pipenv virtual environments:
$pipenv --venv
You can activate the project’s virtual environment by running
$ pipenv shell
and deactivate it by running
$ exit
You can use $ pipenv shell and use pip commands such as list and -U to upgrade packages.
$ pipenv --rm = remove pipenv virtualenv
So all your pipenv environments are stored in the following path ~/.local/share/virutlaenvs directory.
When you are ready to push it to production, you must lock your environment to ensure you replicate the same one in production.
$ pipenv lock
Once you get your code and Pipfile.lock in your production environment, you can install all packages with:
$ pipenv install
If you ever need to ignore pipfile.lock file you can do:
$ pipenv install --ignore-pipfile
==========================================
Create a file .profile into your home directory and append the following 2 lines to append to PATH env var:
export PATH=$PATH:/c/users/YourUserName/appdata/roaming/python/python310/site-packages
export PATH=$PATH:/c/users/YourUserName/appdata/roaming/python/python310/scripts
Reference links:
https://docs.pipenv.org/basics/
https://towardsdatascience.com/python-environment-101-1d68bda3094d