fossasia / visdom

A flexible tool for creating, organizing, and sharing visualizations of live, rich data. Supports Torch and Numpy.
Apache License 2.0
10.01k stars 1.14k forks source link

Problems executing example code #9

Closed alexanderkoller closed 7 years ago

alexanderkoller commented 7 years ago

Hi,

thanks for a really cool-looking library!

I'm having trouble running the demo code, using an Anaconda distribution of Python 3.5 on macOS Sierra. I installed Visdom using "pip install visdom".

Here's the example code from your README:

import visdom
import numpy as np
vis = visdom.Visdom()
vis.text('Hello, world!')
vis.image(np.ones((10, 10, 3)))

When the vis.text call is executed, the following error message appears in the "python -m visdom.server" process:

ERROR:tornado.application:Uncaught exception POST /events (::1)
HTTPServerRequest(protocol='http', host='localhost:8097', method='POST', uri='/events', version='HTTP/1.1', remote_ip='::1', headers={'User-Agent': 'python-requests/2.9.1', 'Host': 'localhost:8097', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '97', 'Accept-Encoding': 'gzip, deflate'})
Traceback (most recent call last):
  File "/Users/koller/anaconda/envs/py35/lib/python3.5/site-packages/tornado/web.py", line 1443, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "/Users/koller/anaconda/envs/py35/lib/python3.5/site-packages/visdom/server.py", line 227, in post
    args = json.loads(self.request.body)
  File "/Users/koller/anaconda/envs/py35/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
ERROR:root:ERROR: 500: {'exc_info': (<class 'TypeError'>, TypeError("the JSON object must be str, not 'bytes'",), <traceback object at 0x10919db88>)}
ERROR:tornado.access:500 POST /events (::1) 2.66ms

Nothing appears in the browser window. Then, when I try to execute the vis.image call, this call throws the following exception on the client side. The same exception happens if I don't call vis.text before, so perhaps these are two unrelated issues?

Traceback (most recent call last):
  File "/Users/koller/anaconda/envs/py35/lib/python3.5/site-packages/PIL/ImageFile.py", line 461, in _save
    fh = fp.fileno()
io.UnsupportedOperation: fileno

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/koller/anaconda/envs/py35/lib/python3.5/site-packages/visdom/__init__.py", line 241, in image
    im.save(buf, format='JPEG', quality=opts['jpgquality'])
  File "/Users/koller/anaconda/envs/py35/lib/python3.5/site-packages/PIL/Image.py", line 1728, in save
    save_handler(self, fp, filename)
  File "/Users/koller/anaconda/envs/py35/lib/python3.5/site-packages/PIL/JpegImagePlugin.py", line 734, in _save
    ImageFile._save(im, fp, [("jpeg", (0, 0)+im.size, 0, rawmode)], bufsize)
  File "/Users/koller/anaconda/envs/py35/lib/python3.5/site-packages/PIL/ImageFile.py", line 476, in _save
    fp.write(d)
TypeError: string argument expected, got 'bytes'

No further error message appears on the server side.

Any thoughts on what might be causing this?

Best, Alexander.

lantiga commented 7 years ago

These issues should have been fixed in master. Try cloning the repository, running 'python setup.py install' and running the demo again.

alexanderkoller commented 7 years ago

Thanks, this works!