Install Python Package from Github [Linux and Windows]

This article is about how to install python package from GitHub, for this, you must have the latest version of python installed in your system.

 

How to check if python is installed or not?

Before getting into the procedure of how to install python package from GitHub the latest python version installed is a must. So to check if your system has python go to the command prompt and type

Advertisement
python -version

This will be the output if the version is installed

install python package from github

But if it is not installed, python not found will be displayed on the command prompt.

 

Install Python Package from Github on Windows

How to install a python package using pip install?

Usually, in python, a package is installed using the command

pip install packageName

But sometimes, if a newer version of the library of the package is available, it might not get installed using this command, for that, we will learn how to download and install python package from Github.

 

Install Python Package from Github in VSCode

First of all, go to Github, and search for the package that you need to install. You need to make sure that the package has a “setup.py” file, for example in our case if we want to install the flask package from GitHub, I will search for the flask python package, and then check if it has the file “setup.py”.

After making sure that there is a setup file, go to your VS Code, in case you do not have VS Code, you can download it and set up a virtual environment.

Advertisement

The command to set up the virtual environment is :

python -m venv environmentName

After setting up the environment, go to your source using the following command

source environmentName/bin/activate

And then write the following command to install the package using GitHub

pip install -e git+github-url-of-the-package#egg=packageName

In my case, if I want to download the flask package I will write

pip install -e git+https://github.com/pallets/flask#egg=flask

Install a Python Package from Github Using Windows Command Prompt

This method is simpler, just open the windows command prompt to install  python package from GitHub  and write the following command

pip install -e git+github-url-of-the-package#egg=packageName

In my case, if I want to download the flask package I will write

Advertisement
pip install -e git+https://github.com/pallets/flask#egg=flask

The command prompt will show some output and will notify if the package is installed or not.

If successful, the following output will be shown :

Obtaining flask from git+https://github.com/pallets/flask#egg=flask
  Cloning https://github.com/pallets/flask to c:\users\azka\desktop\python\src\flask
  Running command git clone --filter=blob:none --quiet https://github.com/pallets/flask 'C:\Users\Azka\Desktop\python\src\flask'
  Resolved https://github.com/pallets/flask to commit 9b44bf2818d8e3cde422ad7f43fb33dfc6737289
  Preparing metadata (setup.py) ... done
Requirement already satisfied: Werkzeug>=2.0 in c:\users\azka\appdata\local\programs\python\python310\lib\site-packages (from flask) (2.1.2)Requirement already satisfied: Jinja2>=3.0 in c:\users\azka\appdata\roaming\python\python310\site-packages (from flask) (3.0.3)
Requirement already satisfied: itsdangerous>=2.0 in c:\users\azka\appdata\local\programs\python\python310\lib\site-packages (from flask) (2.1.2)
Requirement already satisfied: click>=8.0 in c:\users\azka\appdata\local\programs\python\python310\lib\site-packages (from flask) (8.1.3)   
Requirement already satisfied: colorama in c:\users\azka\appdata\roaming\python\python310\site-packages (from click>=8.0->flask) (0.4.4)    
Requirement already satisfied: MarkupSafe>=2.0 in c:\users\azka\appdata\roaming\python\python310\site-packages (from Jinja2>=3.0->flask) (2.1.0)
Installing collected packages: flask
  Running setup.py develop for flask
Successfully installed flask

 

Install Python Package from GitHub on Linux

Install git on Linux (pre-requisite)

To install python package from Github on Linux you need to have git installed on your system. for that please type the following command on your Linux terminal.

sudo apt install git

The following output will be shown :

Reading package lists... Done
Building dependency tree
Reading state information... Done
git is already the newest version (1:2.25.1-1ubuntu3.4).
git set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.

install python package from github

 

Install python package on Linux using pip

Let's suppose we want to install a package "moviespy" from GitHub, go to the Linux terminal and type the following command:

pip install git+https://github.com/Zulko/moviepy

The following output will be shown

Advertisement
Successfully installed decorator-5.1.1 imageio-2.19.3 imageio-ffmpeg-0.4.7 moviepy-2.0.0.dev2 numpy-1.23.0 pillow-9.2.0 proglog-0.1.10 tqdm-4.64.0

 

Install Python Package from Github by cloning the git repository

Another way to install Python Package from Github by cloning the git repository, for this process write the following commands

$ git clone link-to-github-repository

In my case

$ git clone https://github.com/Zulko/moviepy

the output will be as follows

Cloning into 'moviepy'...
remote: Enumerating objects: 8208, done.
remote: Counting objects: 100% (44/44), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 8208 (delta 20), reused 19 (delta 6), pack-reused 8164
Receiving objects: 100% (8208/8208), 40.60 MiB | 1017.00 KiB/s, done.
Resolving deltas: 100% (5776/5776), done.
Updating files: 100% (255/255), done.

Then move to the project directory using the cd command

$ cd moviepy

Run the setup.py file to install the package

$ sudo python setup.py install

 

Conclusion

In this article we have studied how to install a package from python using GitHub, we have studied installation in two environments, one is the virtual environment created using vs code and one is using the windows command prompt.

Advertisement

 

Further study

Python Packages
Install python and pip

 

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment

X