qutip/qutip-notebooks

pip Error in My Binder

nathanshammah opened this issue · 3 comments

My Binder currently fails to run, with the following error:

Waiting for build to start...
Picked Git content provider.
Cloning into '/tmp/repo2docker_ixj09qr'...
HEAD is now at 58598bb notebooks for td_Qobj (#55)
Building conda environment for python=3.7Using PythonBuildPack builder
Building conda environment for python=3.7Building conda environment for python=3.7Step 1/44 : FROM buildpack-deps:bionic
 ---> d69026b2a83e
Step 2/44 : ENV DEBIAN_FRONTEND=noninteractive
 ---> Using cache
 ---> 192b16cfde14
Step 3/44 : RUN apt-get -qq update &&     apt-get -qq install --yes --no-install-recommends locales > /dev/null &&     apt-get -qq purge &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 595f738a8c46
Step 4/44 : RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen &&     locale-gen
 ---> Using cache
 ---> 0ca33f3a05e7
Step 5/44 : ENV LC_ALL en_US.UTF-8
 ---> Using cache
 ---> 8300b0327311
Step 6/44 : ENV LANG en_US.UTF-8
 ---> Using cache
 ---> de921b66e926
Step 7/44 : ENV LANGUAGE en_US.UTF-8
 ---> Using cache
 ---> f5195ac8b0ef
Step 8/44 : ENV SHELL /bin/bash
 ---> Using cache
 ---> 7d5fcc61ce14
Step 9/44 : ARG NB_USER
 ---> Using cache
 ---> e113eb2ce6e7
Step 10/44 : ARG NB_UID
 ---> Using cache
 ---> 59a9521c79dd
Step 11/44 : ENV USER ${NB_USER}
 ---> Using cache
 ---> 2344f491a8ea
Step 12/44 : ENV HOME /home/${NB_USER}
 ---> Using cache
 ---> 8a38b7ca0763
Step 13/44 : RUN adduser --disabled-password     --gecos "Default user"     --uid ${NB_UID}     ${NB_USER}
 ---> Using cache
 ---> 776413092bcf
Step 14/44 : RUN wget --quiet -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key |  apt-key add - &&    DISTRO="bionic" &&     echo "deb https://deb.nodesource.com/node_10.x $DISTRO main" >> /etc/apt/sources.list.d/nodesource.list &&     echo "deb-src https://deb.nodesource.com/node_10.x $DISTRO main" >> /etc/apt/sources.list.d/nodesource.list
 ---> Using cache
 ---> 128d1ae635b6
Step 15/44 : RUN apt-get -qq update &&     apt-get -qq install --yes --no-install-recommends        less    nodejs        unzip        > /dev/null &&     apt-get -qq purge &&     apt-get -qq clean &&     rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 5bb84dca03d6
Step 16/44 : EXPOSE 8888
 ---> Using cache
 ---> 1af010bda129
Step 17/44 : ENV APP_BASE /srv
 ---> Using cache
 ---> 015efe9eaf03
Step 18/44 : ENV NPM_DIR ${APP_BASE}/npm
 ---> Using cache
 ---> 152da49fbce8
Step 19/44 : ENV NPM_CONFIG_GLOBALCONFIG ${NPM_DIR}/npmrc
 ---> Using cache
 ---> 537762385c84
Step 20/44 : ENV CONDA_DIR ${APP_BASE}/conda
 ---> Using cache
 ---> afe392763a3d
Step 21/44 : ENV NB_PYTHON_PREFIX ${CONDA_DIR}
 ---> Using cache
 ---> 382122268dcc
Step 22/44 : ENV KERNEL_PYTHON_PREFIX ${NB_PYTHON_PREFIX}
 ---> Using cache
 ---> 18f0c1167cc8
Step 23/44 : ENV PATH ${CONDA_DIR}/bin:${NPM_DIR}/bin:${PATH}
 ---> Using cache
 ---> 0c35fe554388
Step 24/44 : COPY conda/install-miniconda.bash /tmp/install-miniconda.bash
 ---> Using cache
 ---> e7ca95dbadaf
Step 25/44 : COPY conda/environment.py-3.7.frozen.yml /tmp/environment.yml
 ---> Using cache
 ---> 6a53125296df
Step 26/44 : RUN mkdir -p ${NPM_DIR} && chown -R ${NB_USER}:${NB_USER} ${NPM_DIR}
 ---> Using cache
 ---> 7bb2261b8c4e
Step 27/44 : USER ${NB_USER}
 ---> Using cache
 ---> 67db6f602037
Step 28/44 : RUN npm config --global set prefix ${NPM_DIR}
 ---> Using cache
 ---> b13da8d472b9
Step 29/44 : USER root
 ---> Using cache
 ---> 247b0fe2ba13
Step 30/44 : RUN bash /tmp/install-miniconda.bash && rm /tmp/install-miniconda.bash /tmp/environment.yml
 ---> Using cache
 ---> 6106f398136d
Step 31/44 : ARG REPO_DIR=${HOME}
 ---> Using cache
 ---> 5f272ae52e5b
Step 32/44 : ENV REPO_DIR ${REPO_DIR}
 ---> Using cache
 ---> 3d3d88d89c36
Step 33/44 : WORKDIR ${REPO_DIR}
 ---> Using cache
 ---> a14cf6460bfe
Step 34/44 : ENV PATH ${HOME}/.local/bin:${REPO_DIR}/.local/bin:${PATH}
 ---> Using cache
 ---> d578c461852f
Step 35/44 : USER root
 ---> Using cache
 ---> 3ada60f44fa9
Step 36/44 : COPY src/ ${REPO_DIR}
 ---> 0b603a66c55c
Step 37/44 : RUN chown -R ${NB_USER}:${NB_USER} ${REPO_DIR}
 ---> Running in 6ca7049264d5
Removing intermediate container 6ca7049264d5
 ---> 5f8ce9fe3063
Step 38/44 : USER ${NB_USER}
 ---> Running in 313d594d0834
Removing intermediate container 313d594d0834
 ---> fd4fa76f2391
Step 39/44 : RUN pip install "pip<19" && ${KERNEL_PYTHON_PREFIX}/bin/pip install --no-cache-dir -r "requirements.txt"
 ---> Running in a5ec8ce350ee
Collecting pip<19
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
Installing collected packages: pip
  Found existing installation: pip 19.0.3
    Uninstalling pip-19.0.3:
      Successfully uninstalled pip-19.0.3
Successfully installed pip-18.1
Collecting cython>=0.21 (from -r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/ab/1b/85223a9d7d39ea8d0dec76785ef5e2aa7a82a3eaa92cb7becd2a64cef663/Cython-0.29.6-cp37-cp37m-manylinux1_x86_64.whl (2.1MB)
Collecting numpy>=1.8 (from -r requirements.txt (line 2))
  Downloading https://files.pythonhosted.org/packages/91/e7/6c780e612d245cca62bc3ba8e263038f7c144a96a54f877f3714a0e8427e/numpy-1.16.2-cp37-cp37m-manylinux1_x86_64.whl (17.3MB)
Collecting scipy>=0.14 (from -r requirements.txt (line 3))
  Downloading https://files.pythonhosted.org/packages/3e/7e/5cee36eee5b3194687232f6150a89a38f784883c612db7f4da2ab190980d/scipy-1.2.1-cp37-cp37m-manylinux1_x86_64.whl (24.8MB)
Collecting matplotlib>=1.2 (from -r requirements.txt (line 4))
  Downloading https://files.pythonhosted.org/packages/83/2a/e47bbd9396af32376863a426baed62d9bf3091f81defd1fe81c5f33b11a3/matplotlib-3.0.3-cp37-cp37m-manylinux1_x86_64.whl (13.0MB)
Collecting qutip>=3.1 (from -r requirements.txt (line 5))
  Downloading https://files.pythonhosted.org/packages/02/fa/c815ed3f060ed96a56843dfdd1b9b68dd4d9924f7e255845c71d9f62d7d1/qutip-4.3.1.tar.gz (5.5MB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-cv49njvv/qutip/setup.py", line 54, in <module>
        from Cython.Build import cythonize
    ModuleNotFoundError: No module named 'Cython'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-cv49njvv/qutip/
You are using pip version 18.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Removing intermediate container a5ec8ce350ee
The command '/bin/sh -c pip install "pip<19" && ${KERNEL_PYTHON_PREFIX}/bin/pip install --no-cache-dir -r "requirements.txt"' returned a non-zero code: 1

There is the option of using an environment.yml file that uses conda, specifying pip inside it.
So far I was able to make it work only with a super-ugly hack:

  • using an environment.yml installing dependencies besides qutip
  • launching a conda install of qutip inside the jupyter notebook (a pip install fails).

The issue reported above occurs also by updating the requirements.txt to more recent versions of dependencies and qutip itself. There are similar open issues online, also regarding scikit-learn. Adding a runtime.txt for python-3.5, as suggested online, did not help.

Also an environment.yml file like

name: Qutip-env
dependencies:
- python==3.6
- pip=18
- matplotlib
- nbconvert
- notebook
- ipywidgets
- pip:
  - cython
  - qutip

does not help. I am looking into this.

#28 is related.

Updating the requirements.txt to

pip==19
cython>=0.29.*
numpy>=1.16
scipy>=1.2
matplotlib>=3.*
qutip>=4.3

does not help, giving the error

 from Cython.Build import cythonize
    ModuleNotFoundError: No module named 'Cython'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-wguhanbi/qutip/
You are using pip version 18.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command. 

My Binder seems to work fine by setting up an environment.yml as

name: notebooksenv
channels:
- conda-forge
dependencies:
- python==3.7
- pip==19.*
- cython
- numpy
- scipy
- matplotlib
- notebook
- qutip

Various attempts failed, probably also the above with python 3.6. It has been tested for qeye(), mesolve and
only in https://github.com/nathanshammah/notebooks but it should work also in qutip-notebooks/.
qutip.about reads:

QuTiP Version:      4.3.1
Numpy Version:      1.16.2
Scipy Version:      1.2.1
Cython Version:     0.29.6
Matplotlib Version: 3.0.3
Python Version:     3.7.0
Number of CPUs:     4
BLAS Info:          Generic
OPENMP Installed:   False
INTEL MKL Ext:      False
Platform Info:      Linux (x86_64)
Installation path:  /srv/conda/lib/python3.7/site-packages/qutip
==============================================================================
Please cite QuTiP in your publication.
==============================================================================
For your convenience a bibtex file can be easily generated using `qutip.cite()`

Raising a PR.