faqs - tsuchiya-lab/Pytutorials GitHub Wiki

FAQs for Python development

How to manually import a library obtained from github or other website

Assume that we are working on an interactive environment like jupyter and that the directory name of library is maxent_graph. (To check if it is a library's directory, see whether it contains __init__.py file.)

The library search path, a list of paths/directories which records libraries' paths, is sys.path, and we append the path of maxent_graph to sys.path. We also assume maxent_graph is located in /Users/someone/Donwloads/maxent_graph_master

import sys
str_path = "/Users/someone/Donwloads/maxent_graph_master"
sys.path.append(str_path)

import maxent_graph  # Now we can import