How to create your own package or Library in PYTHON language like import pandas as pd
Step 1:
mkdir mypackage
cd mypackage
Step 2:
Step 3:
Now save this code in module1.py file
def greet(name):
return f"Hello, {name}!"
Step 4:
Now save this code in module2.py file
def add_numbers(a, b):
return a + b
step 5:
Now save this code in --init--.py file
from .module1 import greet
from .module2 import add_numbers
Step 6:
Now save this code in setup.py file
from setuptools import setup, find_packages
setup(
name="mypackage",
version="0.1",
packages=find_packages(),
install_requires=[], # Add dependencies here if needed
author="Your Name",
author_email="your_email@example.com",
description="A simple Python package",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url="https://github.com/yourusername/mypackage", # Replace with your repo
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.6",
)
Step 7:
Run this in the mypackage/ directory:
Step 8:
Save this code in same folder like (mypackage) you created
from mypackage import greet, add_numbers
print(greet("Alice")) # Output: Hello, Alice!
print(add_numbers(3, 5)) # Output: 8
Now run the code in visual studio after installing the mypackage
pip install mypackage
Super Article.Thanks for sharing this post
ReplyDeleteAws AI Course
Aws AI Certification
"Aws AI Training In Hyderabad
Aws AI Online Training
AI With Aws Online Training
AI With Aws Online Training Course
AI With Aws Training Online
AI With Aws Online Training Hyderabad
AI With Aws Training
Ai With Aws Training Course in Chennai
Ai With Aws Online Training Bangalore
Ai With Aws Online Training India
Thanks for Sharing valuable information.
ReplyDeleteDjango Training
Welcome to Satta Don no1 website Satta Matka kalyan Matka fast result daily free game Kalyan milan Rajdhani ratan main bazar international Play Bazaar Dl Bazaar Etc..
ReplyDeletePlay Bazaar
Play Bazaar
Play Bazaar
Play Bazaar
Play Bazaar