PyClaw examples

110 views
Skip to first unread message

Donna Calhoun

unread,
Aug 31, 2015, 9:21:34 AM8/31/15
to claw-...@googlegroups.com
I am trying to run a PyClaw example, and run into the following problem : 


~...clawpack/pyclaw/examples %  ipython
Python 2.7.10 |Anaconda 2.1.0 (x86_64)| (default, May 28 2015, 17:04:42) 
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from clawpack.pyclaw import examples
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-896ab9d6645e> in <module>()
----> 1 from clawpack.pyclaw import examples

/Users/calhoun/clawpack5.0/clawpack/clawpack/pyclaw/examples/__init__.py in <module>()
----> 1 from advection_1d import advection_1d
      2 from acoustics_1d_homogeneous import acoustics_1d
      3 from acoustics_2d_homogeneous import acoustics_2d
      4 from acoustics_2d_variable import acoustics_2d_interface
      5 from acoustics_3d_variable import acoustics_3d_interface

/Users/calhoun/clawpack5.0/clawpack/clawpack/pyclaw/examples/advection_1d/advection_1d.py in <module>()
     18 """
     19 import numpy as np
---> 20 from clawpack import riemann
     21 
     22 def setup(nx=100, kernel_language='Python', use_petsc=False, solver_type='classic', weno_order=5, 

ImportError: cannot import name riemann

I

My clawpack setup should be up to date, although I have never tried PyClaw before.  I didn’t see any mention of paths on the installation page, so assume that I don’t need any special paths set up. 

I also tried re-installing clawpack/pyclaw via ‘pip’, but that led to other problems (I’ve saved the details), and ultimately, the same error.  

Thanks for any help or suggestions, 

Donna




Kyle Mandli

unread,
Aug 31, 2015, 9:40:28 AM8/31/15
to claw-...@googlegroups.com
Do all the other packages import correctly (like `import clawpack.geoclaw`)?

Kyle
> --
> You received this message because you are subscribed to the Google Groups "claw-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to claw-users+...@googlegroups.com.
> To post to this group, send email to claw-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/claw-users.
> For more options, visit https://groups.google.com/d/optout.

Donna Calhoun

unread,
Aug 31, 2015, 9:43:38 AM8/31/15
to claw-...@googlegroups.com
I just tried importing clawpack.geoclaw, clawpack.pyclaw, clawpack.classic and clawpack.amrclaw

All imported successfully.

Donna

Kyle Mandli

unread,
Aug 31, 2015, 9:45:57 AM8/31/15
to claw-...@googlegroups.com
Does `import clawpack.riemann` work correctly from the same prompt or are you testing this through a script?

Kyle

Donna Calhoun

unread,
Aug 31, 2015, 9:53:21 AM8/31/15
to claw-...@googlegroups.com
No, that is the one package that fails.    


In [1]: import clawpack.pyclaw

In [2]: import clawpack.classic

In [3]: import clawpack.amrclaw

In [4]: import clawpack.geoclaw

In [5]: import clawpack.riemann
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-25eb45a7cf10> in <module>()
----> 1 import clawpack.riemann

ImportError: No module named riemann

Do I need to have particular environment paths set? (other than CLAW?)

Donna

Kyle Mandli

unread,
Aug 31, 2015, 10:15:13 AM8/31/15
to claw-...@googlegroups.com
No, for the Python you should not have to if you installed it (did not use the PYTHONPATH variable).  Can you send along the pip install log?

Donna Calhoun

unread,
Aug 31, 2015, 10:18:00 AM8/31/15
to claw-...@googlegroups.com
What is a “pip install log”?   Should I send it through Google groups?  I have also saved the terminal output of everything I tried, if that is helpful. 

Donna

David Ketcheson

unread,
Aug 31, 2015, 10:37:24 AM8/31/15
to claw-users
What is the output if you type the following at a Python prompt?

import clawpack
print clawpack.__path__

Once you have that path, check whether it has a Riemann subdirectory or not. 

Donna Calhoun

unread,
Aug 31, 2015, 10:43:52 AM8/31/15
to claw-...@googlegroups.com
All looks good : 

In [1]: import clawpack

In [2]: print clawpack.__path__
['/Users/calhoun/clawpack5.0/clawpack/clawpack']

In [3]: 
Do you really want to exit ([y]/n)? y
~ %  ls /Users/calhoun/clawpack5.0/clawpack/clawpack
__init__.py   classic@      petclaw@      setup.py      version.pyc
__init__.pyc  clawutil@     pyclaw@       setup.pyc     visclaw@
amrclaw@      geoclaw@      riemann@      version.py



David Ketcheson

unread,
Aug 31, 2015, 10:47:22 AM8/31/15
to claw-users
Huh.  Could you please

ls /Users/calhoun/clawpack5.0/clawpack/clawpack/riemann

?

Donna Calhoun

unread,
Aug 31, 2015, 10:53:58 AM8/31/15
to claw-...@googlegroups.com
(thanks for your help on this) 

~ %  ls /Users/calhoun/clawpack5.0/clawpack/riemann
README.md  rptest/    src/


Kyle Mandli

unread,
Aug 31, 2015, 11:36:33 AM8/31/15
to claw-...@googlegroups.com
Do the `ls /Users/calhoun/clawapack5.0/clawpack/riemann` instead (Python should see this path, not the other).

Kyle

Donna Calhoun

unread,
Aug 31, 2015, 11:52:30 AM8/31/15
to claw-...@googlegroups.com
(I assume ‘clawapack5.0’ was a typo)

~ %  ls /Users/calhoun/clawpack5.0/clawpack/riemann
README.md  rptest/    src/

Kyle Mandli

unread,
Aug 31, 2015, 12:01:11 PM8/31/15
to claw-...@googlegroups.com
Yes and I forgot the important part, the second clawpack in there. Try:

ls /Users/calhoun/clawpack5.0/clawpack/clawpack/riemann

like David suggested.

Donna Calhoun

unread,
Aug 31, 2015, 12:09:34 PM8/31/15
to claw-...@googlegroups.com

~ %  ls  /Users/calhoun/clawpack5.0/clawpack/clawpack/riemann
/Users/calhoun/clawpack5.0/clawpack/clawpack/riemann@

And I’ll add : 

~ %  ls -lh /Users/calhoun/clawpack5.0/clawpack/clawpack/riemann
lrwxr-xr-x  1 calhoun  staff    62B Dec 10  2013 /Users/calhoun/clawpack5.0/clawpack/clawpack/riemann@ -> /Users/calhoun/clawpack5.0/clawpack/riemann/src/python/riemann 

~ %  ls /Users/calhoun/clawpack5.0/clawpack/riemann/src/python/riemann
src@

~ %  ls /Users/calhoun/clawpack5.0/clawpack/riemann/src/python/riemann/src
/Users/calhoun/clawpack5.0/clawpack/riemann/src/python/riemann/src@

~ %  ls -lh /Users/calhoun/clawpack5.0/clawpack/riemann/src/python/riemann/src
lrwxr-xr-x  1 calhoun  staff    47B Dec 10  2013 /Users/calhoun/clawpack5.0/clawpack/riemann/src/python/riemann/src@ -> /Users/calhoun/clawpack5.0/clawpack/riemann/src

And finally :

~ %  ls -lh /Users/calhoun/clawpack5.0/clawpack/riemann/src
total 1992
-rwxr-xr-x  1 calhoun  staff   2.8K Aug 30 21:27 __init__.py*
-rw-r--r--  1 calhoun  staff   3.6K Aug 30 21:56 __init__.pyc
-rw-r--r--  1 calhoun  staff    79B Dec 15  2014 acoustics_1D_constants.py
.........


Have the symbolic links gotten tangled? 

Kyle Mandli

unread,
Aug 31, 2015, 1:58:34 PM8/31/15
to claw-...@googlegroups.com
Maybe, we did change around some of the paths for Riemann to actually make it simpler. Unless you have something in the Riemann repos I might suggest deleting the entire thing and recloning (using submodules you can do `git submodule init riemann` and `git submodule update` or just directly clone the repository via `git clone git://github.com/clawpack/riemann`). This will at least clean up the strange links you seem to have hanging around. If you then try doing a `pip install -e .` from the $CLAW directory hopefully everything should clean itself up.

Kyle

Donna Calhoun

unread,
Aug 31, 2015, 2:18:06 PM8/31/15
to claw-...@googlegroups.com
I’ll give that a try.  But in the meantime, I just tried importing Riemann from a clean install of clawpack, and get a slightly
different error message : 

~/tmp/clawpack %  ipython --no-banner

In [1]: import clawpack.riemann
********************************************************************
Warning: Some Riemannn solvers were not able to be imported.
 Did you run "pip install" in your clawpack directory?
Traceback (most recent call last):
  File "clawpack/riemann/__init__.py", line 52, in <module>
    import acoustics_1D
ImportError: No module named acoustics_1D
********************************************************************

So then (still in my clean install tmp/clawpack), I did a submodule update in clawpack, and a fetch origin from clawpack/riemann, and nothing new was brought in.  

I tried ‘pip install’ from clawpack (as per instructions above) : 

~/tmp/clawpack %  pip install
You must give at least one requirement to install (see "pip help install")
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

or

~/tmp/clawpack %  pip install -e

Usage:   
  pip install [options] <requirement specifier> [package-index-options] ...
  pip install [options] -r <requirements file> [package-index-options] ...
  pip install [options] [-e] <vcs project url> ...
  pip install [options] [-e] <local project path> ...
  pip install [options] <archive url/path> ...

-e option requires an argument

My version of pip : 

~/tmp/clawpack %  pip --version
pip 7.1.2 from //anaconda/lib/python2.7/site-packages (python 2.7)





To unsubscribe from this group and stop receiving emails from it, send an email to claw-users+un...@googlegroups.com.

To post to this group, send email to claw-...@googlegroups.com.
Visit this group at http://groups.google.com/group/claw-users.
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups "claw-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to claw-users+un...@googlegroups.com.

Kyle Mandli

unread,
Aug 31, 2015, 2:20:45 PM8/31/15
to claw-...@googlegroups.com
Some of the Riemann solvers need to be built which will happen when pip install (or python setup.py install) is run. The second attempt you missed the period (current directory) in the install (hopefully that way works). My guess is that you may have had some mixup as to where one of the installations linked to and everything is confused now.

Kyle

Donna Calhoun

unread,
Aug 31, 2015, 3:22:17 PM8/31/15
to claw-...@googlegroups.com
Okay, so I tried reinstalling riemann in my original installation (removed original riemann; did git clone; submodule update), and still couldn't import riemann. But then I reinstalled clawpack/clawpack, and now I can import riemann, and run the original example I wanted to try.

Thanks for your help,

Donna

Kyle Mandli

unread,
Aug 31, 2015, 4:06:54 PM8/31/15
to claw-...@googlegroups.com
There may have been some vestigial links somewhere that was messing up things (like the link $CLAW/clawpack/riemann). Glad it is now working though.

Kyle
Reply all
Reply to author
Forward
0 new messages