Top "Python-import" questions

For questions about importing modules in Python

Use 'import module' or 'from module import'?

I've tried to find a comprehensive guide on whether it is best to use import module or from module import. …

python python-import
Check if Python Package is installed

What's a good way to check if a package is installed while within a Python script? I know it's easy …

python package skype python-import
Why is Python running my module when I import it, and how do I stop it?

I have a Python program I'm building that can be run in either of 2 ways: the first is to call "…

python module python-import
Python: Best way to add to sys.path relative to the current running script

I have a directory full of scripts (let's say project/bin). I also have a library located in project/lib …

python python-import
Visibility of global variables in imported modules

I've run into a bit of a wall importing modules in a Python script. I'll do my best to describe …

python namespaces mysql-python python-2.6 python-import
How to dynamically load a Python class

Given a string of a Python class, e.g. my_package.my_module.MyClass, what is the best possible way …

python reflection python-import
Why can't Python import Image from PIL?

The single line that I am trying to run is the following: from PIL import Image However simple this may …

python python-imaging-library importerror python-import pillow
Reading file using relative path in python project

Say I have a python project that is structured as follows: project /data test.csv /package __init__.py module.py …

python python-3.x io relative-path python-import
Why use sys.path.append(path) instead of sys.path.insert(1, path)?

Edit: based on a Ulf Rompe's comment, it is important you use "1" instead of "0", otherwise you will break sys.path. …

python path python-import pythonpath
Sibling package imports

I've tried reading through questions about sibling imports and even the package documentation, but I've yet to find an answer. …

python packages python-import siblings