datacarpentry / python-ecology-lesson

Data Analysis and Visualization in Python for Ecologists
https://datacarpentry.org/python-ecology-lesson
Other
163 stars 307 forks source link

[Setup] ggplot fails to install from conda-forge using python 3.6 / Anaconda 4.3.1 #164

Closed omsai closed 7 years ago

omsai commented 7 years ago

It looks like ggplot is only compatible with python 3.4 and not 3.6?

On March 30, 2017, a user reported installing the Python ggplot package fails to install using conda-forge. Below was their report:

MWC02N71WMG3QT:~ vn54$ conda install -c conda-forge ggplot
Fetching package metadata .............
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
  - ggplot -> python 3.4*
  - python 3.6*
Use "conda info <package>" to see the dependencies for each package.
MWC02N71WMG3QT:~ vn54$ conda info <package>
-bash: syntax error near unexpected token `newline'
MWC02N71WMG3QT:~ vn54$ 

Sandeep Namburi confirmed this is the case for both macOS and GNU/Linux and suspects it may also impact Windows.

As a workaround for getting attendees setup for the workshop, in some cases one use pip instead:

pip install -U ggplot

pip is provided by anaconda, but the user would need to have chosen add to anaconda to their PATH.

However in other cases, it ggplot complains of missing PyQt4.

I don't use anaconda and use my distro + pip packages instead, so I played with it in a VM:

user@ubuntu16:~$ wget https://repo.continuum.io/archive/Anaconda3-4.3.1-Linux-x86_64.sh
user@ubuntu16:~$ bash Anaconda3-4.3.1-Linux-x86_64.sh
# Installed using the defaults options
user@ubuntu16:~$ export PATH=/home/user/anaconda3/bin:$PATH
user@ubuntu16:~$ conda install -c conda-forge ggplot
Fetching package metadata ...........
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
  - ggplot -> python 3.4*
  - python 3.6*
Use "conda info <package>" to see the dependencies for each package.
user@ubuntu16:~$ conda info ggplot
Fetching package metadata .........
NoPackagesFoundError: Package missing in current linux-64 channels: 
  - ggplot
# One can see package info from https://anaconda.org/conda-forge/ggplot
user@ubuntu16:~$ which pip
/home/user/anaconda3/bin/pip
user@ubuntu16:~$ pip install -U ggplot
Collecting ggplot
  Downloading ggplot-0.11.5-py2.py3-none-any.whl (2.2MB)
    100% |████████████████████████████████| 2.2MB 704kB/s 
Requirement already up-to-date: patsy>=0.4 in ./anaconda3/lib/python3.6/site-packages (from ggplot)
Requirement already up-to-date: matplotlib in ./anaconda3/lib/python3.6/site-packages (from ggplot)
Requirement already up-to-date: pandas in ./anaconda3/lib/python3.6/site-packages (from ggplot)
Collecting numpy (from ggplot)
  Downloading numpy-1.12.1-cp36-cp36m-manylinux1_x86_64.whl (16.8MB)
    100% |████████████████████████████████| 16.8MB 108kB/s 
Collecting scipy (from ggplot)
  Downloading scipy-0.19.0-cp36-cp36m-manylinux1_x86_64.whl (48.2MB)
    100% |████████████████████████████████| 48.2MB 34kB/s 
Collecting statsmodels (from ggplot)
  Downloading statsmodels-0.8.0-cp36-cp36m-manylinux1_x86_64.whl (6.3MB)
    100% |████████████████████████████████| 6.3MB 293kB/s 
Requirement already up-to-date: six in ./anaconda3/lib/python3.6/site-packages (from ggplot)
Collecting brewer2mpl (from ggplot)
  Downloading brewer2mpl-1.4.1-py2.py3-none-any.whl
Requirement already up-to-date: cycler in ./anaconda3/lib/python3.6/site-packages (from ggplot)
Requirement already up-to-date: python-dateutil in ./anaconda3/lib/python3.6/site-packages (from matplotlib->ggplot)
Collecting pytz (from matplotlib->ggplot)
  Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
    100% |████████████████████████████████| 491kB 3.2MB/s 
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 (from matplotlib->ggplot)
  Downloading pyparsing-2.2.0-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 5.6MB/s 
Installing collected packages: numpy, scipy, statsmodels, brewer2mpl, ggplot, pytz, pyparsing
  Found existing installation: numpy 1.11.3
    Uninstalling numpy-1.11.3:
      Successfully uninstalled numpy-1.11.3
  Found existing installation: scipy 0.18.1
    Uninstalling scipy-0.18.1:
      Successfully uninstalled scipy-0.18.1
  Found existing installation: statsmodels 0.6.1
    Uninstalling statsmodels-0.6.1:
      Successfully uninstalled statsmodels-0.6.1
  Found existing installation: pytz 2016.10
    DEPRECATION: Uninstalling a distutils installed project (pytz) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling pytz-2016.10:
      Successfully uninstalled pytz-2016.10
  Found existing installation: pyparsing 2.1.4
    Uninstalling pyparsing-2.1.4:
      Successfully uninstalled pyparsing-2.1.4
Successfully installed brewer2mpl-1.4.1 ggplot-0.11.5 numpy-1.12.1 pyparsing-2.2.0 pytz-2017.2 scipy-0.19.0 statsmodels-0.8.0

However in the VM, testing the ggplot library using python -m ggplot fails to detect the installed PyQt4:

user@ubuntu16:~$ python -m ggplot
Traceback (most recent call last):
  File "/home/user/anaconda3/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/user/anaconda3/lib/python3.6/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/home/user/anaconda3/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/home/user/anaconda3/lib/python3.6/site-packages/ggplot/__init__.py", line 19, in <module>
    from .geoms import geom_area, geom_blank, geom_boxplot, geom_line, geom_point, geom_jitter, geom_histogram, geom_density, geom_hline, geom_vline, geom_bar, geom_abline, geom_tile, geom_rect, geom_bin2d, geom_step, geom_text, geom_path, geom_ribbon, geom_now_its_art, geom_violin, geom_errorbar, geom_polygon
  File "/home/user/anaconda3/lib/python3.6/site-packages/ggplot/geoms/__init__.py", line 1, in <module>
    from .geom_abline import geom_abline
  File "/home/user/anaconda3/lib/python3.6/site-packages/ggplot/geoms/geom_abline.py", line 1, in <module>
    from .geom import geom
  File "/home/user/anaconda3/lib/python3.6/site-packages/ggplot/geoms/geom.py", line 3, in <module>
    from ..ggplot import ggplot
  File "/home/user/anaconda3/lib/python3.6/site-packages/ggplot/ggplot.py", line 4, in <module>
    import matplotlib.pyplot as plt
  File "/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5agg.py", line 16, in <module>
    from .backend_qt5 import QtCore
  File "/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 26, in <module>
    import matplotlib.backends.qt_editor.figureoptions as figureoptions
  File "/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 20, in <module>
    import matplotlib.backends.qt_editor.formlayout as formlayout
  File "/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 56, in <module>
    from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
  File "/home/user/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_compat.py", line 137, in <module>
    from PyQt4 import QtCore, QtGui
ModuleNotFoundError: No module named 'PyQt4'

Looking at ~/anaconda3/lib it seems to use Qt5 instead of Qt4.

This fault persists using the git version per the official python ggplot installation instructions on pypi: https://pypi.python.org/pypi/ggplot

user@ubuntu16:~$ pip install -U git+https://github.com/yhat/ggplot.git
# Still complains about missing PyQt4 when trying to import ggplot

Also I'm not 100% sure how we report problems upstream to the anaconda folks. I've seen their developers respond on the software-carpentry discuss mailing list, so for lack of my understanding the proper process I'm going to report the issue there and link back here.

Edit: mailing list report: http://lists.software-carpentry.org/pipermail/discuss/2017-March/005165.html

omsai commented 7 years ago

It turns out conda supports other python versions. One can create a environment with an older python 3.4 as follows:

conda create -n py34 python=3.4 anaconda
source activate py34
conda install -c conda-forge ggplot

Will update the configuration problems and solutions page