Category Archives: Python

Mirror of Magnus Lie Hetland’s Levenshtein Distance in Python

 

http://web.archive.org/web/20060701000000*/http://www.hetland.org/python/distance.py

http://web.archive.org/web/20061010073401/http://hetland.org/python/distance.py

Linked from: http://people.cs.pitt.edu/~kirk/cs1501/Pruhs/Fall2006/Assignments/editdistance/Levenshtein%20Distance.htm

Why am I getting the Python Error “ImportError: No module named py”?

Question: Why am I getting the following error in Python “ImportError: No module named py”?

Simple answer: Somewhere, one of your imports ends in “.py”  Deleting that should solve the issue.

 

Example 1

import test.py

Python is trying to import the package named “test” with a module named “py” that doesn’t exist within the file “test.py”

Correct way of importing “test.py”

import test

 

Example 2

The Qt Designer allows you to subclass/extend a widget by “promoting” the base class and then specifying a header file that contains your defined class.  If the header file variable in Qt Designer has “.py” you also get the error when your GUI is compiled.  The incorrect inclusion of “testlistview.py”:

Correct way:

 

Further reading:

Python Quick Reference from Create Daily Links Text

Month List: index starts at 1

compatible with datetime module date.month

monthList[0] is an empty string

 

Weekday List:  index starts at 0

compatible with datetime module date.weekday()

Using isoweekday()? get the list here

 

Python String Lowercase

use “.lower()” example dayName.lower()

 

Python String Replace

str.replace(old, new[, max])

str.replace(” “,”-“)

 

Python String  Range Slice (Trim)

 

Python datetime double digit month and day values

 

Python Print Newline

[Solved] … is not a supported wheel on this platform

The error message “… is not a supported wheel on this platform.” means there is some incompatibility between the wheel package and your version of Python.

Two common sources of this error are that…

  1. the package expects a different system type (32-bit vs 64-bit).
  2. your system doesn’t have or can’t identify the necessary version of Python i.e. you only have a 3.x version installed, but the package requires Python 2.7.

Fix for Issue 1

The fix is either to download the other version (32-bit if you downloaded 64-bit and vice versa) or change the wheel’s file name if you know you need the version you have.

For example:

scipy-0.15.1-cp34-none-win_amd64.whl becomes

scipy-0.15.1-cp34-none-win32.whl

Installing again using the new file name should successfully install the package.

Fix for Issue 2

You will need to ensure the version of Python you have and the version the package expects are the same.  You might have to either install a different version of python or a different version of the package.  If the package only supports a certain version of Python, then the only fix is to download the required Python version.

 

Where to find wheel packages?

Unofficial Windows Binaries for Python Extension Packages – http://www.lfd.uci.edu/~gohlke/pythonlibs/

 

Python packages I’ve had this issue with: