thegooglecodearchive / sfepy

Automatically exported from code.google.com/p/sfepy
0 stars 0 forks source link

ImportError: Import by filename is not supported. #80

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

./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.

Original issue reported on code.google.com by nils...@googlemail.com on 3 Mar 2009 at 7:15

GoogleCodeExporter commented 9 years ago
./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))
>>> <type 'exceptions.ImportError'>
Traceback (most recent call last):
  File "./runTests.py", line 222, in <module>
    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 <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.

Original comment by nils...@googlemail.com on 3 Mar 2009 at 7:44

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

Original comment by robert.c...@gmail.com on 4 Mar 2009 at 8:03

GoogleCodeExporter commented 9 years ago
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.

Original comment by robert.c...@gmail.com on 4 Mar 2009 at 8:52

GoogleCodeExporter commented 9 years ago
Hi Robert,

In that case I use python2.6

Original comment by nils...@googlemail.com on 4 Mar 2009 at 5:59

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I do not have access to Python 2.6 right now - could you try the attached 
patch, please?

Original comment by robert.c...@gmail.com on 5 Mar 2009 at 9:06

Attachments:

GoogleCodeExporter commented 9 years ago
If you can wait until the evening ;-) I will apply your patch and inform you 
then.

Original comment by nils...@googlemail.com on 5 Mar 2009 at 9:17

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

Original comment by robert.c...@gmail.com on 5 Mar 2009 at 9:29

Attachments:

GoogleCodeExporter commented 9 years ago
You know, those gentoo guys don't even have python2.6 yet. :)

Original comment by ondrej.c...@gmail.com on 5 Mar 2009 at 2:33

GoogleCodeExporter commented 9 years ago
Stop kidding and test it :)

Original comment by robert.c...@gmail.com on 5 Mar 2009 at 2:52

GoogleCodeExporter commented 9 years ago
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.

Original comment by ondrej.c...@gmail.com on 5 Mar 2009 at 3:00

GoogleCodeExporter commented 9 years ago
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.

Original comment by robert.c...@gmail.com on 5 Mar 2009 at 3:06

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

Original comment by ondrej.c...@gmail.com on 5 Mar 2009 at 3:12

GoogleCodeExporter commented 9 years ago
No problem with that :)

Original comment by robert.c...@gmail.com on 5 Mar 2009 at 3:14

GoogleCodeExporter commented 9 years ago
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

Original comment by nils...@googlemail.com on 5 Mar 2009 at 5:31

GoogleCodeExporter commented 9 years ago
So sfepy now works with Python 2.6, great! Thanks for the testing.

Original comment by robert.c...@gmail.com on 6 Mar 2009 at 9:20

GoogleCodeExporter commented 9 years ago
Migrated to http://github.com/sfepy/sfepy/issues/83

Original comment by robert.c...@gmail.com on 30 Jan 2012 at 10:25