How To Install A Python Library
With deep roots in open source, and as a founding member of the Python Foundation, ActiveState actively contributes to the Python customs. Nosotros offer the convenience, security and support that your enterprise needs while existence compatible with the open source distribution of Python.
Download ActiveState Python to go started or contact us to acquire more than near using ActiveState Python in your organization.
Nigh Python packages are now designed to be compatible with Python's pip packet managing director. But if you take 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 ever ensure that a Python installation containing the necessary files needed for installing packages is in identify by post-obit the Installation Requirements .
Packages That Cannot exist Installed with Pip
Preliminary Steps to take:
- Download the packet and extract it into a local directory.
- If the package includes its own set of installation instructions, they should be followed. Otherwise, the virtually 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 up a command or terminal window and:
- cd into the root directory where setup.py is located
- 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-appointment 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 past PyPA (Python Packaging Dominance) in 'Sample Project'.
Sample Project
Sample Project is a template parcel 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/main/setup.py ]
setup.py is the build script for packages built with setuptools.
Setup.py Instance (Non-Annotated)
import setuptools with open("README.medico", "r") equally fh: long_description = fh.read() setuptools.setup( name="<template-bundle-username>", # Replace with your username version="ane.0.0", author=" <authorname> ", author_email=" <authorname@templatepackage.com> ", clarification=" <Template Setup.py parcel> ", long_description=long_description, long_description_content_type="text/markdown", url=" <https://github.com/authorname/templatepackage> ", packages=setuptools.find_packages(), classifiers=[ "Programming Linguistic communication :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: Os Independent", ], python_requires='>=3.six', )
How ActiveState Tin Assistance
ActiveState provides a unified cross-platform toolchain for modern Python packet management. It can supplant the complex and hard-to-maintain in-house solutions built from multiple package managers, environs management tools and other solutions.
Past adopting the ActiveState Platform, developers tin:
- Automated building of packages from source, including link C libraries without the demand for a local build environment.
- Automated resolution of dependencies (or suggestions on how to manually resolve conflicts), ensuring that your surround always contains a fix of known skilful dependencies that work together.
- Primal management of a unmarried source of truth for your surroundings that can exist deployed with a single command to all evolution and CI/CD environments, ensuring consequent reproducibility.
- Automatic installation of virtual Python environments on Windows or Linux without requiring prior setup.
- The power to find, set up and automatically rebuild vulnerable environments, thereby enhancing security and dramatically reducing fourth dimension 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'due south CLI, the State Tool, which acts equally a universal package manager for Python, and provides access to most of the features offered by the Platform.
Modern Python Package Management
ActiveState provides a unified cantankerous-platform toolchain for modern Python package direction. Information technology tin replace the complex and hard-to-maintain in-firm solutions congenital from multiple bundle 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 parcel and environs management overhead
- Eliminate dependency hell
- Reduce "works on my machine" issues
Ultimately, developers that are willing to prefer the ActiveState Platform will spend less time wrestling with tooling and more time focused on doing what they do best: coding.
To attempt the ActiveState Platform for yourself, sign-up for a costless business relationship.
Recommended Reads
How to Install Python Packages using a Script
How to Update All Python Packages
Source: https://www.activestate.com/resources/quick-reads/how-to-manually-install-python-packages/
Posted by: parentfactiven.blogspot.com
0 Response to "How To Install A Python Library"
Post a Comment