I've found a third party module which I would like to use. How do I technically import that module?
Particularly, I want to use a module called context_manager. obviously, I cannot just import garlicsim.general_misc.context_manager
because it won't find garlicsim
. So what should I write to import the thing?
EDIT: I'm using both Python 3.x and Python 2.x and I'd like to get answers relevant to both versions.
The primary way to install third-party modules is to use Python's pip tool. This tool securely downloads and installs Python modules onto your computer from https://pypi.python.org/, the website of the Python Software Foundation. PyPI, or the Python Package Index, is a sort of free app store for Python modules.
Imports should be divided according to what is being imported. There are generally three groups: standard library imports (Python's built-in modules) related third party imports (modules that are installed and do not belong to the current application)
append() Function. This is the easiest way to import a Python module by adding the module path to the path variable. The path variable contains the directories Python interpreter looks in for finding modules that were imported in the source files.
In garlicsim's case you'd want to install it following garlicsim's installation instructions. You could also download the code and in the right directory run python setup.py install
for this and almost any other library.
One note, since you may be new to python, is that that's a python 3 library. If you're using python 2 (more likely if you don't know) it won't work right. You'll want to install the python 2 version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With