Is it possible to use import for third party modules in Python? How?
Thanks

Recommended Answers

All 6 Replies

Of course it is possible, third party modules need to be installed with a tool such as pip, then they can be imported. For example if we want to use module unidecode that we find in the python package index, we can open a terminal (or cmd console) and type (on my system, pip for python 3 is named pip3)

pip3 install unidecode

Then in python, we can use (tested with python 3)

>>> import unidecode
>>> unidecode.unidecode("Déjà")
'Deja'

What if I want to modify the third party module? Where can I find it?
And what should I do when I get the following message when I want to install a module:

Could not find a version that satisfies the requirement quakelib (from versions: ) No matching distribution found for quakelib

And, if the only way is installing the module, why should a software provide the module files? Does it mean there is a way of installing a module when you have its code?

Thanks

What if I want to modify the third party module? Where can I find it?

pip show unidecode

Metadata-Version: 2.0
Name: Unidecode
Version: 0.4.20
Summary: ASCII transliterations of Unicode text
Home-page: UNKNOWN
Author: Tomaz Solc
Author-email: tomaz.solc@tablix.org
Installer: pip
License: GPL
Location: /usr/local/lib/python2.7/site-packages
Requires:
Classifiers:
  License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
  Programming Language :: Python
  Programming Language :: Python :: 2
  Programming Language :: Python :: 3
  Topic :: Text Processing
  Topic :: Text Processing :: Filters
Entry-points:
  [console_scripts]
  unidecode = unidecode.util:main

And, if the only way is installing the module, why should a software provide the module files? Does it mean there is a way of installing a module when you have its code?

The answers to these questions and more can be found in one of thousands of Python tutorials, manuals, books and instructional videos online.

And what should I do when I get the following message when I want to install a module

Third party modules don't need to be referenced in the python package index. You must know something about this quakelib module, otherwise you wouldn't try to install it. Use what you know and search engines to find its source code. For example if you find a git repository, you can clone it or fork it and you can install it manually if it has a setup.py file by typing

python setup.py install

in the directory containing this file. If you want to modify the module, you can install it in development mode with python setup.py develop instead.

The answers to these questions and more can be found in one of thousands of Python tutorials, manuals, books and instructional videos online.

So could you give a link to one of them?
I couldn't find anything in my searches.

Sure, here you go.

You need to crawl, walk and run before you start the 110m hurdles.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.