Categories
Python

判断 Python 模块是否安装

在不加载 module 的情况下判断 module 是否已安装

import imp

class checkModule:
    def check_psutil(self):
        try:
            imp.find_module('psutil')
            found = True
        except ImportError:
            found = False

        if not found:
            raise AssertionError('Module psutil is not installed.')
        else:
            print('Module psutil is installed.')
Categories
Linux/Unix Python

error: invalid Python installation: unable to open /usr/lib/python2.6/config/Makefile (No such file or directory)

安装 Django 时遇到如下的提示:
error: invalid Python installation: unable to open /usr/lib/python2.6/config/Makefile (No such file or directory)
安装所适应的 python-dev 或 python-devel 可以解决这个问题。

The following error was shown while I was installing Django.
error: invalid Python installation: unable to open /usr/lib/python2.6/config/Makefile (No such file or directory)
Installing your distribution's python-dev or python-devel package may solve this problem.