rohith0904
rohith0904

Reputation: 53

How to import external library in python?

Hie can anyone help me out with detailed process of downloading & importing an external library called PyEnchant, to check a spelling of word is valid english word or not

Upvotes: 3

Views: 32750

Answers (4)

SV125
SV125

Reputation: 325

With Windows 10 (64 bit), Python 3.6:

First install pip:

  1. copy the text in this link https://bootstrap.pypa.io/get-pip.py and save it to a file in your preferred folder. Call the file: "get-pip.py"
  2. click on start --> type "cmd" --> right click --> open as administrator
  3. cd C:\Users\yourpath\yourfolder\
  4. get-pip.py install
  5. if a message appears, saying to upgrade: python -m pip install --upgrade pip

Second:

  1. go to https://pypi.python.org/pypi/pyenchant/
  2. download pyenchant-2.0.0-py2.py3.cp27.cp32.cp33.cp34.cp35.cp36.pp27.pp33.pp35-none-win32.whl 3) from the command line opened as administrator: cd C:\Users\yourpath\yourfolder\
  3. py -3.6 -m pip install pyenchant-2.0.0-py2.py3.cp27.cp32.cp33.cp34.cp35.cp36.pp27.pp33.pp35-none-win32.whl

Upvotes: 1

ComputerFellow
ComputerFellow

Reputation: 12108

The official PyEnchant page asks these prerequisites before you install:

Prerequisites

To get PyEnchant up and running, you will need the following software installed:

Python 2.6 or later
The enchant library, version 1.5.0 or later.
    For Windows users, the binary installers below include a pre-built copy of enchant.
    For Mac OSX users, the binary installers below include a pre-built copy of enchant.

For your convenience there's an exe which should be able to do the above - Download it.

If you want to install enchant first, and then pyenchant, then download enchant from here.

Pyenchant is on PyPi, so you should be able to

pip install pyenchant

If you don't have pip, then download get-pip.py and run python get-pip.py (this might require you to have admin privileges)

and then in your python prompt,

>>> import enchant
>>> help(enchant)

From the documentation:

>>> import enchant
>>> d = enchant.Dict("en_US")
>>> d.check("Hello")
True
>>> d.check("Helo")
False
>>> d.suggest("Helo")
['He lo', 'He-lo', 'Hello', 'Helot', 'Help', 'Halo', 'Hell', 'Held', 'Helm', 'Hero', "He'll"]

Upvotes: 2

semptic
semptic

Reputation: 654

You have to install it with

pip install pyenchant

Simple usage Example from the docs:

import enchant
d = enchant.Dict("en_US")
d.check("Hello") # Returns True
d.check("Helo")  # Returns False

For installing pip see: https://pip.pypa.io/en/latest/installing.html#install-pip

Upvotes: 3

Blue Ice
Blue Ice

Reputation: 7922

Before you can install pyEnchant, you must install Enchant from here.

Then, and only then, run

pip install pyenchant

in your console to be able to use pyenchant in your python programs.

Upvotes: 0

Related Questions