sfepy/sfepy — Issue #83: ImportError: Import by filename is not supported.
Author: rc
Created: 2012-01-30 10:25:43+00:00
State: open

./simple.py input/poisson.py
/home/nwagner/git/sfepy/sfepy/base/base.py:11: DeprecationWarning: the sets
module is deprecated
from sets import Set
Traceback (most recent call last):
File "./simple.py", line 10, in <module>
from sfepy.applications import SimpleApp
File "/home/nwagner/git/sfepy/sfepy/applications/__init__.py", line 2, in
<module>
from simple_app import SimpleApp
File "/home/nwagner/git/sfepy/sfepy/applications/simple_app.py", line 5,
in <module>
from sfepy.fem import ProblemDefinition
File "/home/nwagner/git/sfepy/sfepy/fem/__init__.py", line 10, in <module>
from fields import Fields, Field
File "/home/nwagner/git/sfepy/sfepy/fem/fields.py", line 6, in <module>
import sfepy.terms as terms
File "/home/nwagner/git/sfepy/sfepy/terms/__init__.py", line 23, in <module>
term_table = load_classes( term_files, is_term )
File "/home/nwagner/git/sfepy/sfepy/terms/__init__.py", line 14, in
load_classes
mod = __import__( name )
ImportError: Import by filename is not supported.

Migrated from http://code.google.com/p/sfepy/issues/detail?id=80

earlier comments

nils106 said, at 2009-03-03T19:44:28.000Z:

./runTests.py --debug
/home/nwagner/git/sfepy/sfepy/base/base.py:11: DeprecationWarning: the sets module is
deprecated
from sets import Set
<<< directory: tests, test files: 26
<<< tests/test_quadratures.py
sfepy: left over: ['__builtins__', 'ebc_sin', '__file__', '__name__', 'N',
'TestCommon', 'nm', '_filename', '__package__', '__doc__']
{'region_Omega': Struct:Omega, 'region_Gamma_Top': Struct:Gamma_Top,
'region_Omega_2': Struct:Omega_2, 'region_Omega_1': Struct:Omega_1,
'region_Gamma_Bottom': Struct:Gamma_Bottom}
>>> test instance prepared (1 test(s))
>>>
Traceback (most recent call last):
File "./runTests.py", line 222, in
main()
File "./runTests.py", line 217, in main
op.walk( options.test_dir, wrap_run_tests( options ), stats )
File "/usr/lib64/python2.6/posixpath.py", line 224, in walk
func(arg, top, names)
File "./runTests.py", line 148, in run_tests
n_fail, n_total, test_time = run_test( conf_name, options )
File "./runTests.py", line 111, in run_test
ok, n_fail, n_total = test.run( options.debug )
File "/home/nwagner/git/sfepy/sfepy/base/testing.py", line 38, in run
ret = test_method()
File "tests/test_quadratures.py", line 150, in test_problem_creation
from sfepy.solvers.generic import solve_stationary
File "/home/nwagner/git/sfepy/sfepy/solvers/generic.py", line 4, in
from sfepy.fem import ProblemDefinition
File "/home/nwagner/git/sfepy/sfepy/fem/__init__.py", line 10, in
from fields import Fields, Field
File "/home/nwagner/git/sfepy/sfepy/fem/fields.py", line 6, in
import sfepy.terms as terms
File "/home/nwagner/git/sfepy/sfepy/terms/__init__.py", line 23, in
term_table = load_classes( term_files, is_term )
File "/home/nwagner/git/sfepy/sfepy/terms/__init__.py", line 14, in load_classes
mod = __import__( name )
ImportError: Import by filename is not supported.

robert.cimrman said, at 2009-03-04T08:03:56.000Z:

Hi Nils, what is your python version? SfePy is known to work on 2.4.* and 2.5.*. Do
you have 2.6?

robert.cimrman said, at 2009-03-04T08:52:07.000Z:

so it is indeed a 2.6 issue, see http://docs.python.org/whatsnew/2.6.html

Due to an implementation accident, if you passed a file path to the built-in
__import__() function, it would actually import the specified file. This was never
intended to work, however, and the implementation now explicitly checks for this case
and raises an ImportError.

nils106 said, at 2009-03-04T17:59:21.000Z:

Hi Robert,

In that case I use python2.6

robert.cimrman said, at 2009-03-05T09:06:08.000Z:

I do not have access to Python 2.6 right now - could you try the attached patch, please?

nils106 said, at 2009-03-05T09:17:48.000Z:

If you can wait until the evening ;-) I will apply your patch and inform you then.

robert.cimrman said, at 2009-03-05T09:29:08.000Z:

No problem. BTW. the header down to line 'diff --git ...' should not be there (does
it work?). Here is the real patch.

ondrej.certik said, at 2009-03-05T14:33:48.000Z:

You know, those gentoo guys don't even have python2.6 yet. :)

robert.cimrman said, at 2009-03-05T14:52:54.000Z:

Stop kidding and test it :)

ondrej.certik said, at 2009-03-05T15:00:53.000Z:

I don't have numpy/scipy in python2.6, just pure python2.6.

Btw, why don't you use git format-patch? I had to apply your patch with "patch -p0",
imho it is more robust to just use "git am".

Btw2, if you want an account on my fast computer (8 cores), send me your public ssh
key offlist.

robert.cimrman said, at 2009-03-05T15:06:18.000Z:

I see, so let us wait for Nils :)

I do not use patches much - sfepy workflow is much simpler than that of e.g. sympy.
Next time I will try git format-patch.

ondrej.certik said, at 2009-03-05T15:12:15.000Z:

Well, but you want more developers in sfepy, right? :) So you will have to learn it
anyways. :)

robert.cimrman said, at 2009-03-05T15:14:18.000Z:

No problem with that :)

nils106 said, at 2009-03-05T17:31:04.000Z:

Great. I have applied your patch via
patch -p1 < import.patch
patching file sfepy/terms/__init__.py

./runTests.py --debug
...
snip
...
>>> all passed in 10.30 s
26 test file(s) executed in 56.30 s, 0 failure(s) of 34 test(s)

Thank you.

Cheers,
Nils

robert.cimrman said, at 2009-03-06T09:20:06.000Z:

So sfepy now works with Python 2.6, great! Thanks for the testing.