I have been trying PyMC these days, and I wrote a very simple mcmceasy.py. Interestingly, the script runs OK in IPython, however, when I use Python directly, it gives the following traceback:
Traceback (most recent call last):
File "mcmceasy.py", line 2, in <module>
from pymc import MvNormal, MCMC
File "/usr/lib/python2.7/site-packages/pymc/__init__.py", line 55, in <module>
import ScipyDistributions
File "/usr/lib/python2.7/site-packages/pymc/ScipyDistributions.py", line 1, in <module>
import scipy.stats.distributions as sc_dst
File "/usr/lib/python2.7/site-packages/scipy/stats/__init__.py", line 12, in <module>
import mstats
File "/usr/lib/python2.7/site-packages/scipy/stats/mstats.py", line 3, in <module>
from mstats_basic import *
File "/usr/lib/python2.7/site-packages/scipy/stats/mstats_basic.py", line 52, in <module>
import scipy.misc as misc
File "/usr/lib/python2.7/site-packages/scipy/misc/__init__.py", line 20, in <module>
__all__ += common.__all__
NameError: name 'common' is not defined
My question has 2 parts: 1. How to solve this problem with vanilla python shell? 2. What makes IPython free from this error?
Of course I don’t have your script but I’ve successfully run the imports in question from Windows, Linux and OSX versions of 2.6 and 2.7 python in both IPython and python. No errors as you report.
HOWEVER, looking at the “scipy/misc/init.py” the name common is not imported.
The fact that the code works means that common is imported someplace else. Within
scipy.__init__.py, PackageLoader is is imported from numpy and performs scary magic, checking paths of frame in the call stack etc.IPython has different imports from python, especially if you are using the pylab flag. That would make ipython and python different. I’d suggest trying the imports above separately. Calling an import before PyMC does it might be a work-around
Otherwise, you should post your version of numpy which is where the PackageLoader is called from.