Fix Python – How do I update a Python package?

I’m running Ubuntu 9:10 and a package called M2Crypto is installed (version is 0.19.1). I need to download, build and install the latest version of the M2Crypto package (0.20.2).
The 0.19.1 package has files in a number of locations including (/usr/share/pyshared and /usr/lib/pymodules.python2.6).
How can I completely uninstall version 0.19.1 fro….

Fix Python – Standard way to embed version into Python package?

Is there a standard way to associate version string with a Python package in such way that I could do the following?
import foo
print(foo.version)

I would imagine there’s some way to retrieve that data without any extra hardcoding, since minor/major strings are specified in setup.py already. Alternative solution that I found was to have import __….

Fix Python – Relative imports – ModuleNotFoundError: No module named x

This is the first time I’ve really sat down and tried python 3, and seem to be failing miserably. I have the following two files:

test.py
config.py

config.py has a few functions defined in it as well as a few variables. I’ve stripped it down to the following:
config.py
debug = True

test.py
import config
print (config.debug)

I also have an __in….

Fix Python – Python 3: ImportError “No Module named Setuptools”

I’m having troubles with installing packages in Python 3.
I have always installed packages with setup.py install. But now, when I try to install the ansicolors package I get:
importerror “No Module named Setuptools”

I have no idea what to do because I didn’t have setuptools installed in the past. Still, I was able to install many packages with se….

Fix Python – How to fix “Attempted relative import in non-package” even with __init__.py

I’m trying to follow PEP 328, with the following directory structure:
pkg/
__init__.py
components/
core.py
__init__.py
tests/
core_test.py
__init__.py

In core_test.py I have the following import statement
from ..components.core import GameLoopEvents

However, when I run, I get the following error:
tests$ python core_test.py ….