What you have here is a package called "modulename" which contains a sub-module also called "modulename". In other words, "modulename.modulename". This is perfectly valid in Python. The modulename.py module is in turn trying to import something from somewhere else in the package also called "modulename". That's why it looks like it's trying to import "from itself". Admittedly confusing which is why I usually try not to use naming like this myself ;)
The import isn't working because you're adding the top-level package called "modulename" to sys.path when you should be adding the parent directory. The package structure is important.
You can tell a directory in a Python project is a package because it contains an __init__.py
file.
Update: When I first wrote this it was aimed at Python 2.x. In Python 3 a directory containing Python modules is automatically treated as a package, regardless whether or not there's an __init__.py
.
By the way, I don't know what software you're trying to use, but in the off chance it includes a setup.py you should use that to install it.
(As an aside, I don't believe the original file actually contains import modulename from modulename as mod
as that's invalid syntax.)