After researching a bit on this topic and also based on the comments to thw query, the most likely probability for this error to occur is the mixing up of Python 2.7 and Python 3 versions and the presence of some stale .pyc files within the site-packages directory.
When you import a module within another module, it works fine because, the same Python interpreter (v3.3) is used to load the Python modules and hence there is no problem encountered.
since you are facing a problem only when you run it from the command line, it would help to verify which version of python you are using to execute these scripts.
At the command prompt type :
python -version
this should give you the version of python you are currently using to run your script. Make sure that it is version 3.3. Else, you will need to modify the PATH environment variable to make the path for the 3.3 version of the interpreter ( say c:\python33 ) come before any other python interpretor version (say c:\python27 ). You can do this as below:
SET PATH=c:\python33;%PATH%
assuming Python 3.3 interpreter is present within c:\python33
An edit based on the response from JoChen
One of the following cases is definitely true:
- plot_rzsaldo.0.5.3.2_topng.py supports only the 2.7 version of Python. This is the file that is causing the Bad magic Number error; not your module file.
- There is a stray plot_rzsaldo.0.5.3.2_topng.pyc file somewhere within the directories from where python loads it's files which is generated by Python 2.7.
How did I say that the version of python is 2.7? - Well the answer lies in the magic number which is printed as \x03\xF3\r\n (L.S.Byte -03 and M.S.Byte- F3). This when converted to decimal gives 62211 which is the magic number for Python 2.7a0 62211 (refer this link for details). Another interesting link also details the structure of .pyc files. This link details about the sensitivity of .pyc files to the interpreter version.
Given that we do not have access to all the source code and the modules being imported, this is the best that I can answer after my research.