I am having a similar problem.
I have now worked out how to copy my helper file to the correct location, in my case is:
'/Users/sydney/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages'

When I type the following at the IPython prompt I get no error message;
import findGraphParametersV2

And the following led me to believe all was well.

I type in the following:
In [19]: dir(findGraphParametersV2)

Out[19]:
['__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 'findGraphParameters',
 'np',
 'pylab']

However, when I use the import statement in my program I get a runtime error as follows:

<ipython-input-14-abb1b897e8b9> in <module>()
----> 1 CapitalSimulation(51, 4000.0, 20.0, 20.0, 100, 1.0, 0.0, 40.0, 1.0)

/Users/sydney/My_Documents/Political_Economy/Capital_Simulation/Capital/Current version/CapitalWithProdV14.py in CapitalSimulation(number_of_cycles, capital_advanced, unit_constant_capital, wagerate, labour_powers, productivity, prodinc, work_duration, labour_intensity) 525 lnsurplusvalue, lnvariablecapital, lnconstantcapital, 526 lnlabourpowers, lnnewvaluecreated, rationvtoac,
--> 527                         rationvtorc)
    528
529 plotDataV2(cycles, AdvancedCapital, lnAdvancedCapital, RealisedCapital,

TypeError: 'module' object is not callable

I do not really understand what Steven is recommending below.
Is it an init statement in a file or is it an independent file.

Thanks to you all.

Sydney


On 02/06/2014 03:55, Steven D'Aprano wrote:
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.



--
Sydney Shall

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to