How to install a package in Python (programming language) using pip (five different lines of codes)?

Suppose we want to install “Graphviz” package developed by Sebastian Bank (https://pypi.org/project/graphviz/) using pip, we can use one of the five different lines of codes as follows:

For installation of the package in Python, write the following:

pip install graphviz

or

!pip install graphviz

or

$pip install graphviz

It will either install graphviz or it will return an outcome “SyntaxError: invalid syntax.” Then the following lines of code could be used:

import pip
package_name='graphviz'
pip.main(['install', package_name])

It will either install graphviz or it will return an outcome “AttributeError: module ‘pip’ has no attribute ‘main’.”  Then the following lines of codes could be used:

from pip._internal import main
package_name='graphviz '
main.main(['install', package_name])

It will install graphviz. When problems occur during pip installation, it is best to review the package, install the most recent version of pip, and work with this version.

saypeople

SayPeople.com gives you the news and information about Science, Research, Technology, Business and Islam.