Python is the most picked language for quick analysis and experiments. Its vast support of libraries makes the developers get helped easily
Lets make our hands dirty
To start with we will have to install python. Prefer to be with the latest
sudo apt update && sudo apt install python3
sudo apt install python3-pip
After installing python3 and pip, we are good to start with using interactive shell with python
python3
To install other depndant packages lets create a virtual environment in the project folder. Preferably its considered to have separate virtual environments for each projects, so that all your dependencies are isolated from each other. Ofcourse this would eatup your disk space in having multiple copy of the same depenencies.
However there are multiple ways we can create an environment for pythoon. Lets see each one by one
pip install virtualenv
Test the virtualenv installatioon
virtualenv --version
Now lets create virtualenv for our project
virtualenv mypy_env
Once you execute this command, a directory named mypy_env is created. For our project this would be the directory whhich consists of all the defined libraries and packages. Now lets activate the virtualenv for our development
source mypy_env/bin/activate
Now you see the below in your cli prompt
(mypy_env)
Lets see a glimpse of poetry Poetry is a single tool that offers dependency management, packaging, and virtual environment creation. Poetry replaces setup.py, requirements.txt, setup.cfg, MANIFEST.in and Pipfile with a simple pyproject.toml based project format
pip install poetry
To use the poetry tool for our projects, get into the directory of your project Run peotry init to initiate with the interactive setup
poetry init
Follow the steps as interactive shell displays to say YES and hit Enter.
To activate
poetry shell
poetry config virtualenvs.in-project true
##Lets see how to add a depndency. Once you add you ready to use the environment
poetry add numpy
poetry show