Error trying to use python in R

I had a problem with the library tslib when I tried to install pandas. This is my code:

library(reticulate)
use_condaenv("r-reticulate")
py_install("pandas")
py_install("matplotlib")
py_install("ggplot")
py_install("numpy")
import matplotlib
import numpy as np
import pandas as pd
from ggplot import diamonds

matplotlib.style.use("ggplot")

AttributeError: module 'pandas' has no attribute 'tslib'

Detailed traceback: 
  File "<string>", line 1, in <module>
  File "/home/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/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/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/ggplot/geoms/__init__.py", line 1, in <module>
    from .geom_abline import geom_abline
  File "/home/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/ggplot/geoms/geom_abline.py", line 1, in <module>
    from .geom import geom
  File "/home/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/ggplot/geoms/geom.py", line 3, in <module>
    from ..ggplot import ggplot
  File "/home/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/ggplot/ggplot.py", line 13, in <module>
    from .aes import aes
  File "/home/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/ggplot/aes.py", line 11, in <module>
    from . import utils
  File "/home/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/ggplot/utils.py", line 81, in <module>
    pd.tslib.Timestamp,

Then, I removed tslib:

date_types = (
    pd.tslib.Timestamp,
    pd.DatetimeIndex,
    pd.Period,
    pd.PeriodIndex,
    datetime.datetime,
    datetime.time
)
date_types = (
    pd.Timestamp,
    pd.DatetimeIndex,
    pd.Period,
    pd.PeriodIndex,
    datetime.datetime,
    datetime.time
)

And put a comment on :

from pandas.lib # import Timestamp

To solve the problem, but I have a new problem :

ImportError: /lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/matplotlib/../../.././libpng16.so.16)

Detailed traceback: 
  File "<string>", line 1, in <module>
  File "/home/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/matplotlib/__init__.py", line 207, in <module>
    _check_versions()
  File "/home/rstudio-user/.local/share/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/matplotlib/__init__.py", line 192, in _check_versions
    from . import ft2font

What can I do?.

It seems that what you are trying to do relies on this utility libz.so.1, so can you try installing that (through your OS)

How can I do that?..

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.