nipy / PySurfer

Cortical neuroimaging visualization in Python
https://pysurfer.github.io/
BSD 3-Clause "New" or "Revised" License
240 stars 97 forks source link

pysurfer on python3.6 status #217

Closed mwaskom closed 6 years ago

mwaskom commented 6 years ago

I wanted to keep track of the status of pysurfer on python 3.6, which currently seems to work, but not as straightforwardly as one would like.

This could also be a wiki page, but I always forget those exist, and ideally this will be "closed" one day. And hopefully we can link to relevant issues in upstream packages.

Here's how I had success getting a conda environment with pysurfer dependencies and a few other tools that are useful for doing science.

conda create -n mayavi pip 
. activate mayavi
conda install -c conda-forge mayavi
conda install -c conda-forge mayavi matplotlib pandas scipy seaborn ipython jupyter
pip install pysurfer

Then I was able to start IPython and use pysurfer with the following environment variable settings:

QT_API=pyqt
ETS_TOOLKIT=qt4

As I understand it, the current blocker is that Mayavi's dependencies require PyQT4, whereas the main anaconda matplotlib only works with PyQT5. However, there are now conda-forge packages with sufficient dependency chains.

Does this look right? Does anyone know what issues to track to see when Mayavi will work with PyQT5?

mwaskom commented 6 years ago

It was also helpful to install an ipykernel in the new environment so I could just pop open an notebook that uses it without otherwise interrupting my workflow:

python -m ipykernel install --user --name mayavi --display-name "Python 3.6 (mayavi)"
larsoner commented 6 years ago

We have a working Python3.6 + PyQt5 env over at MNE:

https://github.com/mne-tools/mne-python/blob/master/environment.yml

The only bug I've hit so far is the lack of HiDPI support on OSX.

mwaskom commented 6 years ago

So things are working on development versions of pyface/traits/etc. but not released versions?

larsoner commented 6 years ago

Yeah. In theory once they each cut a new release the pin-to-hashes can go away.

mwaskom commented 6 years ago

Nice! Testing on my system with the above recipe, it looks like the HiDPI bug is a PyQT5-only problem?

larsoner commented 6 years ago

Yeah I think so, because PyQt5 supports HiDPI but it isn't used properly by VTK7.1:

https://github.com/enthought/mayavi/issues/84#issuecomment-337951014

mwaskom commented 6 years ago

The other annoying (unrelated to Python 3, but might only be fixed there) issue is that the IPython gui event loop has to be initialized after importing pysurfer/mayavi, which is this issue: https://github.com/ipython/ipython/issues/10384

christianbrodbeck commented 6 years ago

@mwaskom does PySurfer from conda-forge not work for you? My hope is still that one day it should all be possible with conda install -c conda-forge pysurfer, on macOS that is currently not possible because of VTK (https://github.com/conda-forge/vtk-feedstock/issues/10).

Edit: I assume you are on macOS and that is why you don't use conda-forge

mwaskom commented 6 years ago

@christianbrodbeck mostly I did not know pysurfer was on conda-forge

But since mayavi depends on vtk, I'm confused why my recipe was not a problem on macOS, but installing pysurfer would be?

christianbrodbeck commented 6 years ago

@mwaskom if I try to do that I get

(py3) $ conda install -c conda-forge mayavi
Fetching package metadata .................
Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:
  - mayavi -> apptools 4.2.1 -> python 2.7*
  - python 3.6*
Use "conda info <package>" to see the dependencies for each package.

and

$ conda create -n py3mayavi python=3 mayavi
Fetching package metadata .................
Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:
  - mayavi -> apptools 4.2.1 -> python 2.7*
  - python 3*
Use "conda info <package>" to see the dependencies for each package.
christianbrodbeck commented 6 years ago

https://github.com/conda-forge/pysurfer-feedstock (https://github.com/nipy/PySurfer/issues/174) Do you want to be added as maintainer?

mwaskom commented 6 years ago

I don't really know anything about conda-forge, but I imagine figuring out what differs between the mayavi feedstock and yours will make it work.

christianbrodbeck commented 6 years ago

Is it possible you have another channel in your configuration that has mayavi (e.g. clinicalgraphics) and your command is pulling maya from there? A problem for that in Conda forge is that all the dependencies need to come from defaults or Conda-forge, so we can’t enable a PySurfer build until mayavi is also working.

mwaskom commented 6 years ago

How do you find out what channels one has available? This is all on a laptop I got on Friday, however, so I doubt I have anything beyond what you get by default and what I specified above.

mwaskom commented 6 years ago

To be clear, this is what I saw that made me expect it to work: https://github.com/conda-forge/mayavi-feedstock/pull/13

christianbrodbeck commented 6 years ago

conda config --get channels

You should also see what channels libraries are coming from when conda asks for confirmation, e.g.

$ conda install pysurfer
Fetching package metadata .................
Solving package specifications: .

Package plan for installation in environment //anaconda:

The following NEW packages will be INSTALLED:

    apptools:           4.4.0-py27_0                     
    envisage:           4.6.0-py27h805c201_0             
    imageio:            2.2.0-py27h37746d9_0             
    mayavi:             4.5.0-py27_0                     
    nibabel:            2.2.0-py27_0          conda-forge
    pydicom:            0.9.9-py27_0          conda-forge
    pysurfer:           0.8.0-py27_0          conda-forge
    traitsui:           5.1.0-py27_0          conda-forge
    vtk:                6.3.0-py27_1                     

I think that recipe actually has the macOS build disabled: skip: True # [osx] (https://github.com/conda-forge/mayavi-feedstock/blob/master/recipe/meta.yaml#L21)?

mwaskom commented 6 years ago

Oh, hah, I see the problem here. Even though I'm using anaconda3, my recipe gave me a python 2 environment.

What a stupid mess.

Edit to add: only on macOS. The recipe worked fine and produced a python 3 environment on linux.

christianbrodbeck commented 6 years ago

It was too good to be true :)

mwaskom commented 6 years ago

Maybe anaconda will raise another round of VC funding and they'll actually package mayavi on python 3 🙄

christianbrodbeck commented 6 years ago

@Korijn hinted at the possibility to upload VTK to conda-forge manually (https://github.com/conda-forge/vtk-feedstock/issues/10#issuecomment-338498249), if that were possible all the other issues might be solvable on conda-forge...

christianbrodbeck commented 6 years ago

@mwaskom if you have access to linux, does conda install pysurfer work there?

mwaskom commented 6 years ago

Seems to!

[kianilab-cs1 ~]$ conda create -n pysurfer -c conda-forge python=3.6 pysurfer
Fetching package metadata .............
Solving package specifications: .

Package plan for installation in environment /home/mwaskom/anaconda/envs/pysurfer:

The following NEW packages will be INSTALLED:

    apptools:        4.4.0-py36_0          conda-forge
    ca-certificates: 2017.7.27.1-0         conda-forge
    cairo:           1.14.6-4              conda-forge
    certifi:         2017.7.27.1-py36_0    conda-forge
    configobj:       5.0.6-py36_0                     
    cycler:          0.10.0-py36_0         conda-forge
    envisage:        4.5.1-py36_0          conda-forge
    expat:           2.2.1-0               conda-forge
    fontconfig:      2.12.1-4              conda-forge
    freetype:        2.7-1                 conda-forge
    future:          0.16.0-py36_0         conda-forge
    gettext:         0.19.7-1              conda-forge
    glib:            2.51.4-0              conda-forge
    graphite2:       1.3.9-0               conda-forge
    h5py:            2.7.1-py36_1          conda-forge
    harfbuzz:        1.4.3-0               conda-forge
    hdf5:            1.8.18-1              conda-forge
    icu:             58.1-1                conda-forge
    imageio:         2.2.0-py36_0          conda-forge
    intel-openmp:    2018.0.0-h15fc484_7              
    jpeg:            9b-1                  conda-forge
    jsoncpp:         0.10.6-1              conda-forge
    libffi:          3.2.1-3               conda-forge
    libgcc-ng:       7.2.0-h7cc24e2_2                 
    libgfortran:     3.0.0-1                          
    libgfortran-ng:  7.2.0-h9f7466a_2                 
    libiconv:        1.14-4                conda-forge
    libpng:          1.6.28-1              conda-forge
    libstdcxx-ng:    7.2.0-h7a57d05_2                 
    libtiff:         4.0.7-0               conda-forge
    libxml2:         2.9.5-0               conda-forge
    matplotlib:      1.5.3-np113py36_8     conda-forge
    mayavi:          4.5.0-np113py36_2     conda-forge
    mkl:             2018.0.0-hb491cac_4              
    ncurses:         5.9-10                conda-forge
    nibabel:         2.2.0-py36_0          conda-forge
    numpy:           1.13.3-py36ha12f23b_0            
    olefile:         0.44-py36_0           conda-forge
    openssl:         1.0.2l-0              conda-forge
    pango:           1.40.4-0              conda-forge
    pcre:            8.39-0                conda-forge
    pillow:          4.3.0-py36_0          conda-forge
    pip:             9.0.1-py36_0          conda-forge
    pixman:          0.34.0-0              conda-forge
    pydicom:         0.9.9-py36_0          conda-forge
    pyface:          5.1.0-py36_1          conda-forge
    pygments:        2.2.0-py36_0          conda-forge
    pyparsing:       2.2.0-py36_0          conda-forge
    pyqt:            4.11.4-py36_2         conda-forge
    pysurfer:        0.8.0-py36_0          conda-forge
    python:          3.6.3-0               conda-forge
    python-dateutil: 2.6.1-py36_0          conda-forge
    pytz:            2017.2-py36_0         conda-forge
    qt:              4.8.7-7               conda-forge
    readline:        6.2-0                 conda-forge
    scipy:           0.19.1-py36h9976243_3            
    setuptools:      36.6.0-py36_1         conda-forge
    sip:             4.18-py36_1           conda-forge
    six:             1.11.0-py36_1         conda-forge
    sqlite:          3.13.0-1              conda-forge
    tbb:             2018_20170919-0       conda-forge
    tk:              8.5.19-2              conda-forge
    tornado:         4.5.2-py36_0          conda-forge
    traits:          4.6.0-py36_1          conda-forge
    traitsui:        5.1.0-py36_0          conda-forge
    vtk:             7.1.1-py36_202        conda-forge
    wheel:           0.30.0-py_1           conda-forge
    xz:              5.2.3-0               conda-forge
    zlib:            1.2.8-3               conda-forge

Proceed ([y]/n)? y

libgcc-ng-7.2. 100% |########################################| Time: 0:00:00  48.42 MB/s
libgfortran-ng 100% |########################################| Time: 0:00:00  55.96 MB/s
libstdcxx-ng-7 100% |########################################| Time: 0:00:00  58.65 MB/s
numpy-1.13.3-p 100% |########################################| Time: 0:00:00  58.05 MB/s
olefile-0.44-p 100% |########################################| Time: 0:00:00   2.35 MB/s
pillow-4.3.0-p 100% |########################################| Time: 0:00:00   3.81 MB/s
imageio-2.2.0- 100% |########################################| Time: 0:00:00  11.56 MB/s
matplotlib-1.5 100% |########################################| Time: 0:00:00  10.32 MB/s
mayavi-4.5.0-n 100% |########################################| Time: 0:00:01   6.80 MB/s
pysurfer-0.8.0 100% |########################################| Time: 0:00:00   6.53 MB/s
#
# To activate this environment, use:
# > source activate pysurfer
#
# To deactivate an active environment, use:
# > source deactivate
#
Korijn commented 6 years ago

I wish Anaconda would spend some of that funding on travis build time...!

kleinschmidt commented 6 years ago

This works for me, too (Arch linux 4.15).

larsoner commented 6 years ago

Closing as there are workable solutions