NeuroTechX/EEG-ExPy

`wxPython` requirement issue

tmorshed opened this issue · 3 comments

ℹ Computer information

  • Platform OS (e.g Windows, Mac, Linux etc): Fedora 34 & Ubuntu 20.04 (both on amd64)
  • Python Version: 3.7
  • Brain Interface Used (e.g Muse, OpenBCI, Notion etc): None

📝 Provide detailed reproduction steps (if any)

  1. Initiate a fresh OS image (either Fedora 34 or Ubuntu 20.04) on a virtual machine or on bare metal.
  2. Install Miniconda4 (see this link).
  3. Attempt to install the environment:
conda create -n "eeg-notebooks" python=3.7 git pip

conda activate "eeg-notebooks"

git clone https://github.com/NeuroTechX/eeg-notebooks

cd eeg-notebooks

pip install -e .

(reproduced from the eeg-notebooks installation documentation)

✔️ Expected result

The installation process should fetch and install all required packages for eeg-notebooks, including wxpython which is a requirement for PsychoPy 4.

❌ Actual result

The installation process installs all packages except for wxpython, producing the stderr & stdout:

Collecting wxpython
  Using cached wxPython-4.1.1.tar.gz (66.0 MB)
Requirement already satisfied: pillow in /home/taha/miniconda3/envs/eeg-notebooks/lib/python3.7/site-packages (from wxpython) (8.4.0)
Requirement already satisfied: six in /home/taha/miniconda3/envs/eeg-notebooks/lib/python3.7/site-packages (from wxpython) (1.16.0)
Requirement already satisfied: numpy in /home/taha/miniconda3/envs/eeg-notebooks/lib/python3.7/site-packages (from wxpython) (1.21.3)
Building wheels for collected packages: wxpython
  Building wheel for wxpython (setup.py): started
  Building wheel for wxpython (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /home/taha/miniconda3/envs/eeg-notebooks/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-x8eelqvm
       cwd: /tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/
  Complete output (142 lines):
  /home/taha/miniconda3/envs/eeg-notebooks/lib/python3.7/site-packages/setuptools/dist.py:720: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead
    % (opt, underscore_opt)
  /home/taha/miniconda3/envs/eeg-notebooks/lib/python3.7/site-packages/setuptools/dist.py:294: DistDeprecationWarning: use_2to3 is ignored.
    warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
  running bdist_wheel
  running build
  WARNING: Building this way assumes that all generated files have been
  generated already.  If that is not the case then use build.py directly
  to generate the source and perform the build stage.  You can use
  --skip-build with the bdist_* or install commands to avoid this
  message and the wxWidgets and Phoenix build steps in the future.
  
  "/home/taha/miniconda3/envs/eeg-notebooks/bin/python" -u build.py build
  Will build using: "/home/taha/miniconda3/envs/eeg-notebooks/bin/python"
  3.7.11 (default, Jul 27 2021, 14:32:16)
  [GCC 7.5.0]
  Python's architecture is 64bit
  cfg.VERSION: 4.1.1
  
  Running command: build
  Running command: build_wx
  wxWidgets build options: ['--wxpython', '--unicode', '--gtk3']
  Configure options: ['--enable-unicode', '--with-gtk=3', '--enable-sound', '--enable-graphics_ctx', '--enable-display', '--enable-geometry', '--enable-debug_flag', '--enable-optimise', '--disable-debugreport', '--enable-uiactionsim', '--enable-autoidman', '--with-sdl']
  /tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/ext/wxWidgets/configure --enable-unicode --with-gtk=3 --enable-sound --enable-graphics_ctx --enable-display --enable-geometry --enable-debug_flag --enable-optimise --disable-debugreport --enable-uiactionsim --enable-autoidman --with-sdl
  checking build system type... x86_64-pc-linux-gnu
  checking host system type... x86_64-pc-linux-gnu
  checking for toolkit... gtk
  checking for gcc... gcc
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables...
  checking whether we are cross compiling... no
  checking for suffix of object files... o
  checking whether we are using the GNU C compiler... yes
  checking whether gcc accepts -g... yes
  checking for gcc option to accept ISO C89... none needed
  checking whether we are using the Intel C compiler... no
  checking how to run the C preprocessor... gcc -E
  checking for grep that handles long lines and -e... /usr/bin/grep
  checking for egrep... /usr/bin/grep -E
  checking whether gcc needs -traditional... no
  checking for g++... g++
  checking whether we are using the GNU C++ compiler... yes
  checking whether g++ accepts -g... yes
  checking whether we are using the Intel C++ compiler... no
  checking whether we are using the Sun C++ compiler... no
  checking for ar... ar
  checking for ANSI C header files... yes
  checking for sys/types.h... yes
  checking for sys/stat.h... yes
  checking for stdlib.h... yes
  checking for string.h... yes
  checking for memory.h... yes
  checking for strings.h... yes
  checking for inttypes.h... yes
  checking for stdint.h... yes
  checking for unistd.h... yes
  checking for langinfo.h... yes
  checking for wchar.h... yes
  checking for sys/select.h... yes
  checking for cxxabi.h... yes
  checking for an ANSI C-conforming const... yes
  checking for inline... inline
  checking size of short... 2
  checking size of void *... 8
  checking size of int... 4
  checking size of long... 8
  checking size of size_t... 8
  checking size of long long... 8
  checking size of wchar_t... 4
  checking for va_copy... yes
  checking for _FILE_OFFSET_BITS value needed for large files... 64
  checking if large file support is available... yes
  checking for _LARGEFILE_SOURCE value needed for large files... no
  checking whether byte ordering is bigendian... no
  checking for std::wstring in <string>... yes
  checking for std::istream... yes
  checking for std::ostream... yes
  checking for type_traits... yes
  checking for __sync_fetch_and_add and __sync_sub_and_fetch builtins... yes
  checking for libraries directories... /usr/lib64
  checking for cos... no
  checking for floor... no
  checking if floating point functions link without -lm... no
  checking for sin... yes
  checking for ceil... yes
  checking if floating point functions link with -lm... yes
  checking for strtoull... yes
  checking for pkg-config... /usr/bin/pkg-config
  checking pkg-config is at least version 0.9.0... yes
  configure: WARNING: Defaulting to the builtin regex library for Unicode build.
  checking for zlib.h >= 1.1.4... yes
  checking for zlib.h... (cached) yes
  checking for deflate in -lz... yes
  checking for png.h > 0.90... no
  checking for png.h... (cached) no
  configure: WARNING: system png library not found or too old, will use built-in instead
  checking whether png.c file exists... yes
  checking for jpeglib.h... no
  configure: WARNING: system jpeg library not found, will use built-in instead
  checking whether jpeglib.h file exists... yes
  checking lzma.h usability... yes
  checking lzma.h presence... yes
  checking for lzma.h... yes
  checking for lzma_code in -llzma... yes
  checking for jbg_dec_init in -ljbig... no
  checking for LIBTIFF... not found via pkg-config
  checking for tiffio.h... no
  configure: WARNING: system tiff library not found, will use built-in instead
  checking whether tiff.h file exists... yes
  checking for expat.h... no
  configure: WARNING: system expat library not found, will use built-in instead
  checking whether expat.h file exists... yes
  checking for gcc option to accept ISO C99... none needed
  checking for GTK+ version...
  checking for pkg-config... (cached) /usr/bin/pkg-config
  checking pkg-config is at least version 0.16... yes
  checking for GTK+ - version >= 3.0.0... no
  *** Could not run GTK+ test program, checking why...
  *** The test program failed to compile or link. See the file config.log for the
  *** exact error that occurred. This usually means GTK+ is incorrectly installed.
  configure: error:
  The development files for GTK+ were not found. For GTK+ 2, please
  ensure that pkg-config is in the path and that gtk+-2.0.pc is
  installed. For GTK+ 1.2 please check that gtk-config is in the path,
  and that the version is 1.2.3 or above. Also check that the
  libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
  --libs' are in the LD_LIBRARY_PATH or equivalent.
  
  Error running configure
  ERROR: failed building wxWidgets
  Traceback (most recent call last):
    File "build.py", line 1510, in cmd_build_wx
      wxbuild.main(wxDir(), build_options)
    File "/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/buildtools/build_wxwidgets.py", line 373, in main
      "Error running configure")
    File "/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/buildtools/build_wxwidgets.py", line 85, in exitIfError
      raise builder.BuildError(msg)
  buildtools.builder.BuildError: Error running configure
  Finished command: build_wx (0m5.576s)
  Finished command: build (0m5.576s)
  Command '"/home/taha/miniconda3/envs/eeg-notebooks/bin/python" -u build.py build' failed with exit code 1.
  ----------------------------------------
  ERROR: Failed building wheel for wxpython
  Running setup.py clean for wxpython
Failed to build wxpython
Installing collected packages: wxpython
    Running setup.py install for wxpython: started
    Running setup.py install for wxpython: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /home/taha/miniconda3/envs/eeg-notebooks/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-5uktzmlq/install-record.txt --single-version-externally-managed --compile --install-headers /home/taha/miniconda3/envs/eeg-notebooks/include/python3.7m/wxpython
         cwd: /tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/
    Complete output (142 lines):
    /home/taha/miniconda3/envs/eeg-notebooks/lib/python3.7/site-packages/setuptools/dist.py:720: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead
      % (opt, underscore_opt)
    /home/taha/miniconda3/envs/eeg-notebooks/lib/python3.7/site-packages/setuptools/dist.py:294: DistDeprecationWarning: use_2to3 is ignored.
      warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
    running install
    running build
    WARNING: Building this way assumes that all generated files have been
    generated already.  If that is not the case then use build.py directly
    to generate the source and perform the build stage.  You can use
    --skip-build with the bdist_* or install commands to avoid this
    message and the wxWidgets and Phoenix build steps in the future.
    
    "/home/taha/miniconda3/envs/eeg-notebooks/bin/python" -u build.py build
    Will build using: "/home/taha/miniconda3/envs/eeg-notebooks/bin/python"
    3.7.11 (default, Jul 27 2021, 14:32:16)
    [GCC 7.5.0]
    Python's architecture is 64bit
    cfg.VERSION: 4.1.1
    
    Running command: build
    Running command: build_wx
    wxWidgets build options: ['--wxpython', '--unicode', '--gtk3']
    Configure options: ['--enable-unicode', '--with-gtk=3', '--enable-sound', '--enable-graphics_ctx', '--enable-display', '--enable-geometry', '--enable-debug_flag', '--enable-optimise', '--disable-debugreport', '--enable-uiactionsim', '--enable-autoidman', '--with-sdl']
    /tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/ext/wxWidgets/configure --enable-unicode --with-gtk=3 --enable-sound --enable-graphics_ctx --enable-display --enable-geometry --enable-debug_flag --enable-optimise --disable-debugreport --enable-uiactionsim --enable-autoidman --with-sdl
    checking build system type... x86_64-pc-linux-gnu
    checking host system type... x86_64-pc-linux-gnu
    checking for toolkit... gtk
    checking for gcc... gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking whether we are using the Intel C compiler... no
    checking how to run the C preprocessor... gcc -E
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking whether gcc needs -traditional... no
    checking for g++... g++
    checking whether we are using the GNU C++ compiler... yes
    checking whether g++ accepts -g... yes
    checking whether we are using the Intel C++ compiler... no
    checking whether we are using the Sun C++ compiler... no
    checking for ar... ar
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking for langinfo.h... yes
    checking for wchar.h... yes
    checking for sys/select.h... yes
    checking for cxxabi.h... yes
    checking for an ANSI C-conforming const... yes
    checking for inline... inline
    checking size of short... 2
    checking size of void *... 8
    checking size of int... 4
    checking size of long... 8
    checking size of size_t... 8
    checking size of long long... 8
    checking size of wchar_t... 4
    checking for va_copy... yes
    checking for _FILE_OFFSET_BITS value needed for large files... 64
    checking if large file support is available... yes
    checking for _LARGEFILE_SOURCE value needed for large files... no
    checking whether byte ordering is bigendian... no
    checking for std::wstring in <string>... yes
    checking for std::istream... yes
    checking for std::ostream... yes
    checking for type_traits... yes
    checking for __sync_fetch_and_add and __sync_sub_and_fetch builtins... yes
    checking for libraries directories... /usr/lib64
    checking for cos... no
    checking for floor... no
    checking if floating point functions link without -lm... no
    checking for sin... yes
    checking for ceil... yes
    checking if floating point functions link with -lm... yes
    checking for strtoull... yes
    checking for pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    configure: WARNING: Defaulting to the builtin regex library for Unicode build.
    checking for zlib.h >= 1.1.4... yes
    checking for zlib.h... (cached) yes
    checking for deflate in -lz... yes
    checking for png.h > 0.90... no
    checking for png.h... (cached) no
    configure: WARNING: system png library not found or too old, will use built-in instead
    checking whether png.c file exists... yes
    checking for jpeglib.h... no
    configure: WARNING: system jpeg library not found, will use built-in instead
    checking whether jpeglib.h file exists... yes
    checking lzma.h usability... yes
    checking lzma.h presence... yes
    checking for lzma.h... yes
    checking for lzma_code in -llzma... yes
    checking for jbg_dec_init in -ljbig... no
    checking for LIBTIFF... not found via pkg-config
    checking for tiffio.h... no
    configure: WARNING: system tiff library not found, will use built-in instead
    checking whether tiff.h file exists... yes
    checking for expat.h... no
    configure: WARNING: system expat library not found, will use built-in instead
    checking whether expat.h file exists... yes
    checking for gcc option to accept ISO C99... none needed
    checking for GTK+ version...
    checking for pkg-config... (cached) /usr/bin/pkg-config
    checking pkg-config is at least version 0.16... yes
    checking for GTK+ - version >= 3.0.0... no
    *** Could not run GTK+ test program, checking why...
    *** The test program failed to compile or link. See the file config.log for the
    *** exact error that occurred. This usually means GTK+ is incorrectly installed.
    configure: error:
    The development files for GTK+ were not found. For GTK+ 2, please
    ensure that pkg-config is in the path and that gtk+-2.0.pc is
    installed. For GTK+ 1.2 please check that gtk-config is in the path,
    and that the version is 1.2.3 or above. Also check that the
    libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
    --libs' are in the LD_LIBRARY_PATH or equivalent.
    
    Error running configure
    ERROR: failed building wxWidgets
    Traceback (most recent call last):
      File "build.py", line 1510, in cmd_build_wx
        wxbuild.main(wxDir(), build_options)
      File "/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/buildtools/build_wxwidgets.py", line 373, in main
        "Error running configure")
      File "/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/buildtools/build_wxwidgets.py", line 85, in exitIfError
        raise builder.BuildError(msg)
    buildtools.builder.BuildError: Error running configure
    Finished command: build_wx (0m6.6s)
    Finished command: build (0m6.6s)
    Command '"/home/taha/miniconda3/envs/eeg-notebooks/bin/python" -u build.py build' failed with exit code 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/taha/miniconda3/envs/eeg-notebooks/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-c7f0sh1z/wxpython_4ca534779ef94539840b93bd127e59a3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-5uktzmlq/install-record.txt --single-version-externally-managed --compile --install-headers /home/taha/miniconda3/envs/eeg-notebooks/include/python3.7m/wxpython Check the logs for full command output.

The error seems to be only limited to this exact package. All the other requirements have been installed successfully and can be imported and run as well. But wxPython is a requirement for PsychoPy and the user cannot run PsychoPy experiments without fixing this issue.

📷 Screenshots

None

✍️ Additional Info:

This seems to be caused by interference between a default PyPI package called wx and the modern edition of the same package, called wxPython. It is used for making widgets on GTK. wxPython is a requirement for PsychoPy and hence a requirement for eeg-notebooks.
The PsychoPy help page outlines this as a way to fix the issue:

Then fetch a wxPython wheel for your platform from:

https://extras.wxpython.org/wxPython4/extras/linux/gtk3/

and having downloaded the right wheel you can then install it with something like:

pip install path/to/your/wxpython.whl
wxPython>4.0 and doesn’t have universal wheels yet which is why you have to find and install the correct wheel for your particular flavor of linux.

One potential issue is that the wxPython wheels are only available for a limited number of distributions and versions:

  • centos-7
  • centos-8
  • debian-8
  • debian-9
  • debian-10
  • fedora-23
  • fedora-24
  • fedora-26
  • fedora-27
  • fedora-28
  • fedora-29
  • fedora-30
  • fedora-31
  • ubuntu-14.04
  • ubuntu-16.04
  • ubuntu-18.04
  • ubuntu-20.04

Notably, it does not provide wheels for any of the Arch-based architecture Linux distributions (e.g. Manjaro, ArchLinux, Artix). It only supports the RedHat-based and Debian-based platforms. Even then, it has no support for Fedora > 31 (whereas the latest LTS version is 34). The Debian-based distros' wheels seem to be sufficient. The latest LTS versions are included.

🔧 Suggested fixes:

  1. Include the text quoted above from the PsychoPy help page, for fetching and installing the wxPython wheel.
  2. Add a suggestion to the help pages for Linux users to use either of the distros above, or else they will not be able to use PsychoPy experiments.

The build fails because it's missing the GTK3 library, which is a build dependency. On Ubuntu this can be installed with sudo apt install libgtk-3-dev. You might be missing other build dependencies too, at least one more is used in CI:

https://github.com/NeuroTechX/eeg-notebooks/blob/85d286c4ab5d1b9b9b27fbd73d920e2736e2d03b/.github/workflows/test.yml#L44-L47

This prerequisite needs to be mentioned somewhere in the installation guide for Linux users, or tell them to use a wheel like the psychopy docs.

There's a comment about this in the requirements.txt:

https://github.com/NeuroTechX/eeg-notebooks/blob/85d286c4ab5d1b9b9b27fbd73d920e2736e2d03b/requirements.txt#L20-L22

So users on, say, Ubuntu 20.04 & Python 3.8, can use pip install -e . --find-links=https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-20.04/ when installing to ensure that pip won't try to build from source.

One potential issue is that the wxPython wheels are only available for a limited number of distributions and versions: (list of versions)
Notably, it does not provide wheels for any of the Arch-based architecture Linux distributions (e.g. Manjaro, ArchLinux, Artix).

I've been using the Ubuntu-20.04 wheels for wxPython without issue on Arch, so I don't think this should be an issue in most cases. However, there are no wheels for Python 3.9+, I assume when Ubuntu 22.04 is released there will be a new build of wxPython for Python 3.9/3.10... but until then people might have to put up with the very long build time of wxPython for those Python versions (or just use 3.8).

  1. Include the text quoted above from the PsychoPy help page, for fetching and installing the wxPython wheel.
  2. Add a suggestion to the help pages for Linux users to use either of the distros above, or else they will not be able to use PsychoPy experiments.

So yes and yes :)

Also getting this problem now on linux, where I don't have sudo access.

Solution I found =

  • create conda env as per eegnb instructions and activate
  • conda install wxpython
  • pip install . in eeg-notebooks folder

Added the conda part of that to the conda tab of the installation instructions

55a467f

https://neurotechx.github.io/eeg-notebooks/getting_started/installation.html#installing-the-python-library

The extra wheels install line should be added to the venv tab part of that box also.