Top "Python-module" questions

A module is a file containing Python definitions and statements.

What does if __name__ == "__main__": do?

Given the following code, what does the if __name__ == "__main__": do? # Threading example import time, thread def myfunction(string, sleeptime, …

python namespaces main python-module idioms
How to import other Python files?

How do I import other files in Python? How exactly can I import a specific python file like import file.…

python python-import python-module python-packaging
How to import a module given the full path?

How can I load a Python module given its full path? Note that the file can be anywhere in the …

python configuration python-import python-module
How do I find out my python path using python?

How do I find out which directories are listed in my system’s PYTHONPATH variable, from within a Python script (…

python python-module pythonpath
How to write a Python module/package?

I've been making Python scripts for simple tasks at work and never really bothered packaging them for others to use. …

python python-2.7 python-module
Unable to import a module that is definitely installed

After installing mechanize, I don't seem to be able to import it. I have tried installing from pip, easy_install, …

python mechanize python-module
How to do relative imports in Python?

Imagine this directory structure: app/ __init__.py sub1/ __init__.py mod1.py sub2/ __init__.py mod2.py I'm coding mod1, …

python python-import python-module
Installing python module within code

I need to install a package from PyPi straight within my script. Maybe there's some module or distutils (distribute, pip …

python pip python-module pypi
Python: OSError: [Errno 2] No such file or directory: ''

I have a 100 lines, 3 years old python scraper that now bug. Starting lines are: import urllib, re, os, sys, time # …

python python-2.7 python-module
ImportError: libSM.so.6: cannot open shared object file: No such file or directory

When trying to import OpenCV, using import cv2 I get the following error: /usr/local/lib/python2.7/dist-packages/cv2/__init__.…

python opencv python-import importerror python-module