enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

mlab.init_notebook() fails with AttributeError: module 'base64' has no attribute 'encodestring' #1042

Open xaverm opened 3 years ago

xaverm commented 3 years ago

Using mayavi, following https://docs.enthought.com/mayavi/mayavi/tips.html is broken for me. I.e., initializing the ipy backend fails with

AttributeError: module 'base64' has no attribute 'encodestring'

Using the png backend works. The x3d only shows a grey canvas without content.

I'm running an Anaconda environment. Some (hopefully) relevant info about the packages in it:

python                    3.9.4
mayavi                    4.7.2    (build py39h3a0f4c8_4, channel conda-forge) 
ipyevents                 0.8.2 
ipywidgets                7.6.3
jupyter                   1.0.0    
vtk                       9.0.1
pyqt                      5.9.2
qt                        5.9.7
qtpy                      1.9.0

I'll supply any other info needed happily.

The system I'm running on is a 64bit linux, opensuse leap 15.x, with qt 5.9.7. I'm rather sure, it is not an operating system issue, since with older python versions, i.e. python 3.7.x I had no issues of this sort on the same machine.

xaverm commented 3 years ago

While there seems to be no response to my post, and while I'm not a dev, let me attempt a lame fix for those, who experience a similar issue. For me, version 4.7.2 (which conda upgrades mayavi to at most on my present linux Anaconda for python 3.9) ships with two files:

 ../../mayavi/tools/remote/ipy_remote.py
 ../../mayavi/tools/remote/remote_scene.py

The 1st one contains a line

decode_func = getattr(base64, 'decodebytes', getattr(base64, 'decodestring'))

change that to

decode_func = getattr(base64, 'decodebytes', getattr(base64, 'decodebytes'))

the 2nd one contains a line.

encode_func = getattr(base64, 'encodebytes', getattr(base64, 'encodestring'))

change that to

encode_func = getattr(base64, 'encodebytes', getattr(base64, 'encodebytes'))

I have exactly zero understanding, if that is an actual fix or if it will get me into trouble later. At least the ipy backend can be initialized again, and some simple example codes are up and running again. However I also see, that these aforementioned lines seem to be absent in the according files on the present master.

tirkarthi commented 3 years ago

Seems to have been fixed in https://github.com/enthought/mayavi/pull/983

xaverm commented 3 years ago

Last upload for mayavi for python 3.9 to https://anaconda.org/conda-forge/mayavi/ seems to have been 6 months and 19 days ago. #983 seems to have been fixed only after that. Hopefully there will be an update at conda-forge soon.