14th Apr 2021

Let’s publish our own python library


Written By, Smit Parmar

Introduction to Library


Python is one of the high-level programming languages used for web development, AI, machine learning, application development, etc and python Library or Package is a collection of useful functions that eliminates the need of writing the code from scratch!

With the help of the libraries you can access and implement many new things by just importing it in your code.
To install a library in Python, use the following command -+

For ex : pip install django
And to import the library, we can simply write :

So, here we’ll see how we can publish your own library so others can use it like we used to do

Install required built-in libraries

We need to install below mentioned two libraries, to fulfill the process of uploading our library to PyPi.

How to identify the target of the animation

Create one separate folder and inside that, you have to create one more folder which should be named as the name of your library, here it is Mudopy.

Inside your library folder (Mudopy) you need to add all of the code files. It can be more than one.

To get more idea about the code, have a quick look at __init__.py. And don’t forget that your code should contain functions that can be called when someone imports our library.

Upload them on GitHub

Upload the created package( library ) folder to the github.

Creating the files that are required by PyPI

  • LICENSE.txt
  • README.txt
  • MANIFEST.in.txt
  • Setup.py

If getting confused, copy above listed files from Github example

Quick overview of Setup.py

To get download_url go to your repository in Github, and click on the ‘release’ and then click on ‘Create a new release’.

And then define a tag version (version of your library) and in the version-field: v_01(title), you can leave the description empty, and at last click on ‘publish release’.

There is a link on Source Code(tar.gz), right click on that link and select ‘Copy Link Address’ , and paste that link into the download_url field in setup.py.

Now let’s upload newly created four files to the git repository

Create an Account on PyPi

Go to the website of Pypi and register yourself.

Uploading package(Library) to PyPI

Just go to your folder where the setup.py file is stored and open the command prompt

And type the following commands,

  • python setup.py sdist
  • twine upload dist/*
  • Give your username and password of your account in PyPi

And Boom !
Your project uploaded successfully on PyPi. Have a look on it by visiting PyPi.

Installing package/library

Now you can directly install your package by typing the following command in Terminal

Upgrading Library

After uploading the package in PyPi you may face some errors, you can solve such errors and publish your package again by just changing the version name in the setup.py file and repeat step 6.
And than just type,


Hope, now you will be able to publish your own library and help the python community to explore some new things.

“Contribute yourself to make coding easy and simple”

Written By,

Python Developer at Yudiz Solutions Pvt. Ltd