[Tutor] Swampy: No module name World

Steven D'Aprano steve at pearwood.info
Mon Jun 2 04:55:19 CEST 2014


On Sun, Jun 01, 2014 at 08:33:37PM -0500, Charles Agriesti wrote:
> from swampy.World import World
> world = World()
> 
> ImportError: No module name World
> 
> These scripts run with no problem as long as the file location is the 
> python27 folder. But not from outside the folder.

Where does swampy come from? Is it your module? Somebody else's?

It looks to me like it is a bug in swampy. You are trying to use it as 
if it were a package containing a sub-module, but it isn't actually a 
package, just a folder full of modules.

If swampy is somebody else's project, you should report this to them as 
a bug, but if it is yours, then you should be able to fix it by adding 
an empty __init__.py file inside the swampy folder.

My guess is that you have a folder like this inside the python27 folder:


python27
+-- [other python files]
+-- swampy
    +-- World.py


but you need this:

python27
+-- [other python files]
+-- swampy
    +-- __init__.py
    +-- World.py



If this is not what you have, you will need to explain in more detail 
what the layout of your files is, where swampy came from, and where it 
is.


-- 
Steven


More information about the Tutor mailing list