python3 interpreter gives different results than script for scipy.misc.imread
Question: I am trying to read image data into Python as a matrix.

To this extent, I am trying to use
`scipy.misc.imread('image.jpg').astype(np.float)`.

When I execute the proper sequence of steps from a `python3` interpreter,
everything works swimmingly, and I get a matrix as expected.

When I invoke the command from a script (`python3 foo.py`...), however, I get
an error complaining that the argument to convert via `float` cannot be of
type `JpegImageFile`. I've ensured that I've `pip install -U pillow` to ensure
that PIL is available.

What gives? How could this be possible? I've verified over and over that the
same lines of code are executed in each case, the only difference seems to be
that the invocation inside of a script happens inside of a defined function,
but even if I `pdb.set_trace()` from elsewhere in the script the same results
happen.

What could be causing fluctuation in results from the interpreter to the
script?

**EDIT** : OK, to be precise, I am running the `neural_style.py` script from
here: <https://github.com/anishathalye/neural-style> . `scipy`, `numpy`,
`tensorflow`, and `pillow` must be installed. I am using `python3`. Any
parameters for `--content`, `--styles`, and `--output` should work to dupe the
bug.

Full error traceback:

    
    
    Traceback (most recent call last):
      File "neural_style.py", line 150, in <module>
        main()
      File "neural_style.py", line 84, in main
        content_image = imread(options.content)
      File "neural_style.py", line 141, in imread
        return scipy.misc.imread(path).astype(np.float)
    TypeError: float() argument must be a string or a number, not 'JpegImageFile'
    

But, a small simple script such as the following actually works:

    
    
    import numpy as np
    import scipy.misc
    print(scipy.misc.imread('content').astype(np.float))
    


Answer: I figured out the solution to this. The `neural_style.py` script seems to be
getting a different version of `scipy` module (or submodule) due to a side
effect of importing `stylize.py` and, in turn, `vgg.py`. Adding this line:

    
    
    import scipy.misc
    

To the very top of `stylize.py` (in front of `import vgg`) fixes it.

I'm really not sure why, though.

