Install Egg File in Python

Olorunfemi Akinlua Oct 11, 2022
  1. Use setuptools to Install egg File in Python
  2. Unzip to Install egg File in Python
Install Egg File in Python

Long before the pip days, packages were stored as .egg files and were installed via the setuptools component. However, since pip has been introduced to Python, .egg has been replaced by the wheel file, .whl.

If you are working with other packages, there is a possibility to face working with them; though they are deprecated, you can work around them and install the packages stored as .egg files.

In this article, we will discuss how to install the egg file in Python and the tools you can use to achieve this operation.

Use setuptools to Install egg File in Python

Eggs is a distribution format in Python previously used that contains information required by a particular project, from dependencies to environment variables.

Numerous binary formats represent eggs, but the .egg zip file format is the most popular one because it’s useful for sharing projects and simplifies the distribution of Python packages and projects. Alongside the Python code, the .egg file often contains and works with project-wide metadata, C extensions, and package-specific data.

With .egg files, you don’t need to build or install it per se; you need to add it to your sys.path, but it might often require runtime files. Like the popular Python requirement, requirements.txt and .egg files allow the libraries’ specifications to be stated within.

If you happen to need to work with a .egg file and need the non-Python data files, you need to install the .egg file. To install Python Eggs, you can make use of easy_install.

We will base all operations within the Python 2.7 environment on Windows for all the operations here to work.

To access easy_install, you need to install the setuptools package, which helps to download, install, manage, build or remove Python packages.

To install setuptools, we need to download the from the setuptools package page.

After downloading the Python file, you transfer it to the Python27 directory, which would most likely be C:\Python27. Now, open your command prompt, change the directory to C:\Python27 and set the PYTHON_PATH.

set PYTHON_PATH=c:\Python27
set Path=C:\Python27\Scripts

Now, run the following command to install the setuptools package.


The easy_install.exe command is now installed and can be used to install an egg file within your Python 2.7 environment.

Because egg files are now deprecated, it can be hard to find one to show as an example, but we can still create them using the setuptools module.

In our case, we will create an empty egg file with the name delftscope. To create such, we need to create a file that contains the following code.

from setuptools import setup, find_packages
    name = "delftscope",
    version = "0.1",
    packages = find_packages()

Afterward, we can run the following python command, which creates the egg file alongside other directories. These directories include build, dist, and delftscope.egg-info.

python bdist_egg

Within the dist directory, you will find the egg file with the name delftscope-0.1-py3.10.egg.

Now that we have an egg file to work with let’s use the easy_install program to install it. Since we have added it to the OS environment using the set command, we should be able to use easy_install anywhere.

To install the egg file in Python, you can use the following command within your PowerShell.

easy_install .\delftscope-0.1-py3.10.egg


Processing delftscope-0.1-py3.10.egg
Copying delftscope-0.1-py3.10.egg to c:\python27\lib\site-packages
Adding delftscope 0.1 to easy-install.pth file

Installed c:\python27\lib\site-packages\delftscope-0.1-py3.10.egg
Processing dependencies for delftscope==0.1
Searching for delftscope==0.1

With this, you would have installed the module packaged within the egg file. However, Python has moved to the wheel distribution format.

Unzip to Install egg File in Python

Egg files are zip files; therefore, you can unzip this file. So, if you are on Linux, you can use the unzip package to extract its content and then use the to install the package that’s held within the egg file.

To unzip the egg file, the unzip command can be used.

unzip -l delftscope-0.1-py3.10.egg

Afterward, you can access the contents and run the python command to install the package.

python install
Olorunfemi Akinlua avatar Olorunfemi Akinlua avatar

Olorunfemi is a lover of technology and computers. In addition, I write technology and coding content for developers and hobbyists. When not working, I learn to design, among other things.