Skip to content

Instantly share code, notes, and snippets.

@mgpradeepa
Created March 23, 2025 09:32
Show Gist options
  • Save mgpradeepa/312e55780c8cc633461a53b6e8828832 to your computer and use it in GitHub Desktop.
Save mgpradeepa/312e55780c8cc633461a53b6e8828832 to your computer and use it in GitHub Desktop.
Dist about python

Python

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

To install pip

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

Using virtualenv

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) 

Using poetry

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 virtaul envoments in specifi directories by setting virtualenvs.in-project true

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

List all the dependencies

poetry show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment