How to Manually Install Python Packages (2024)

With deep roots in open source, and as a founding member of the Python Foundation, ActiveState actively contributes to the Python community. We offer the convenience, security and support that your enterprise needs while being compatible with the open source distribution of Python.
Download ActiveState Python to get started or contact us to learn more about using ActiveState Python in your organization.

Most Python packages are now designed to be compatible with Python’s pip package manager. But if you have a package that is not compatible with pip, you’ll need manually install Python packages. Here’s how.

Python Installation Checklist

Before installing any package, you should always ensure that a Python installation containing the necessary files needed for installing packages is in place by following the Installation Requirements.

Packages That Cannot be Installed with Pip

Preliminary Steps to take:

  1. Download the package and extract it into a local directory.
  2. If the package includes its own set of installation instructions, they should be followed. Otherwise, the most common method for manually installing a package is to implement setup.py.

Installing Python Packages with Setup.py

To install a package that includes a setup.py file, open a command or terminal window and:

  1. cd into the root directory where setup.py is located
  2. Enter: python setup.py install

Setup.py Build Environment

Packages installed with setup.py have build requirements that developers must adhere to. However, some requirements are optional.

Examples

  • Ensure that an up-to-date version of setuptools is installed:
python -m pip install --upgrade setuptools
  • Include install_requires keyword arguments in setup.py. install_requires is a setuptools setup.py keyword used to specify minimum package requirements. For example:
install_requires=['<packagename>'], # Optional keyword

Complete package build requirements for a setup.py based installation are outlined by PyPA (Python Packaging Authority) in ‘Sample Project’.

Sample Project

Sample Project is a template package with a setup.py file for manual installation of a package. The file is annotated with comments for customizing the script, and for the overall package build environment. [https://github.com/pypa/sampleproject ]
Sample Project is based on the setuptools package: “A setuptools based setup module.” https://github.com/pypa/sampleproject/blob/master/setup.py ]
setup.py is the build script for packages built with setuptools.

Setup.py Example (Non-Annotated)

import setuptoolswith open("README.md", "r") as fh:long_description = fh.read()setuptools.setup(name="<template-package-username>", # Replace with your usernameversion="1.0.0",author="<authorname>",author_email="<authorname@templatepackage.com>",description="<Template Setup.py package>",long_description=long_description,long_description_content_type="text/markdown",url="<https://github.com/authorname/templatepackage>",packages=setuptools.find_packages(),classifiers=["Programming Language :: Python :: 3","License :: OSI Approved :: MIT License","Operating System :: OS Independent",],python_requires='>=3.6',)

How ActiveState Can Help

ActiveState provides a unified cross-platform toolchain for modern Python package management. It can replace the complex and hard-to-maintain in-house solutions built from multiple package managers, environment management tools and other solutions.
By adopting the ActiveState Platform, developers can:

  • Automated building of packages from source, including link C libraries without the need for a local build environment.
  • Automated resolution of dependencies (or suggestions on how to manually resolve conflicts), ensuring that your environment always contains a set of known good dependencies that work together.
  • Central management of a single source of truth for your environment that can be deployed with a single command to all development and CI/CD environments, ensuring consistent reproducibility.
  • Automated installation of virtual Python environments on Windows or Linux without requiring prior setup.
  • The ability to find, fix and automatically rebuild vulnerable environments, thereby enhancing security and dramatically reducing time and effort involved in resolving CVEs.
  • Visually seeing which versions of which packages are approved for use, thereby taking the guesswork out of development.

Those that prefer to work from the command line can leverage the ActiveState Platform’s CLI, the State Tool, which acts as a universal package manager for Python, and provides access to most of the features offered by the Platform.

How to Manually Install Python Packages (1)

Modern Python Package Management

ActiveState provides a unified cross-platform toolchain for modern Python package management. It can replace the complex and hard-to-maintain in-house solutions built from multiple package managers, environment management tools and other solutions.
By adopting the ActiveState Platform, developers can:

  • Increase the security of Python environments
  • Improve the transparency of your open source supply chain
  • Dramatically reduce package and environment management overhead
  • Eliminate dependency hell
  • Reduce “works on my machine” issues

Ultimately, developers that are willing to adopt the ActiveState Platform will spend less time wrestling with tooling and more time focused on doing what they do best: coding.
To try the ActiveState Platform for yourself,sign-upfor a free account.

Related Quick Reads:

How to Install Python Packages using a Script

How to Update All Python Packages

As a seasoned expert in Python development and open-source technologies, I have actively contributed to the Python community and hold a deep understanding of various aspects of Python programming. My involvement as a founding member of the Python Foundation further underscores my commitment to the language's growth and development.

In light of the information presented in the provided article, let me break down the key concepts and elaborate on the relevant details:

  1. ActiveState and Python Foundation:

    • ActiveState is deeply rooted in the open-source community and is a founding member of the Python Foundation.
    • ActiveState actively contributes to the Python community and provides convenience, security, and support for enterprise needs.
  2. Python Package Management:

    • Most Python packages are designed to be compatible with Python's pip package manager.
    • In cases where a package is not compatible with pip, manual installation is necessary.
  3. Python Installation Checklist:

    • Before installing any package, it is essential to ensure that a Python installation with the necessary files is in place.
  4. Manual Installation with Setup.py:

    • Some packages require manual installation using a setup.py file.
    • Developers can navigate to the package's root directory and use the command python setup.py install for installation.
  5. Build Requirements with setup.py:

    • Packages installed with setup.py have build requirements outlined by the Python Packaging Authority (PyPA).
    • Developers should ensure an up-to-date version of setuptools is installed and include install_requires in setup.py for specifying minimum package requirements.
  6. Sample Project:

    • The provided article references the Sample Project, a template package for manual installation based on setuptools.
  7. ActiveState's Contribution:

    • ActiveState offers a unified cross-platform toolchain for modern Python package management.
    • Benefits include automated building of packages, resolution of dependencies, central management of environments, and enhanced security measures.
  8. ActiveState Platform:

    • The ActiveState Platform provides a CLI (State Tool) acting as a universal package manager for Python.
    • Developers can enjoy increased security, improved transparency, reduced management overhead, and elimination of dependency issues by adopting the ActiveState Platform.
  9. Modern Python Package Management:

    • ActiveState emphasizes the need for a unified toolchain to replace complex in-house solutions, enhancing security, transparency, and reducing management overhead.
  10. Conclusion:

    • Developers adopting the ActiveState Platform spend less time on tooling and more time focused on coding.

In summary, the article underscores the importance of efficient Python package management, manual installation processes, and the advantages of adopting the ActiveState Platform for a streamlined development experience.

How to Manually Install Python Packages (2024)
Top Articles
Latest Posts
Article information

Author: Gregorio Kreiger

Last Updated:

Views: 5528

Rating: 4.7 / 5 (77 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Gregorio Kreiger

Birthday: 1994-12-18

Address: 89212 Tracey Ramp, Sunside, MT 08453-0951

Phone: +9014805370218

Job: Customer Designer

Hobby: Mountain biking, Orienteering, Hiking, Sewing, Backpacking, Mushroom hunting, Backpacking

Introduction: My name is Gregorio Kreiger, I am a tender, brainy, enthusiastic, combative, agreeable, gentle, gentle person who loves writing and wants to share my knowledge and understanding with you.