Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with install_keras() on Windows 10 #146

Closed
brandondbutcher opened this issue Oct 3, 2017 · 13 comments
Closed

Trouble with install_keras() on Windows 10 #146

brandondbutcher opened this issue Oct 3, 2017 · 13 comments

Comments

@brandondbutcher
Copy link

I'm having trouble with the install_keras() function on Windows 10. After having installed the keras package and Anaconda 3.6, calling install_keras() continues to produce the errors below. I've done a bunch of googling but not really any luck and not sure how to troubleshoot the error myself.

> library(keras)
> install_keras()
Using r-tensorflow conda environment for TensorFlow installation
Determining latest release of TensorFlow...done
Installing TensorFlow...
Collecting tensorflow==1.3.0 from https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp36-cp36m-win_amd64.whl
  Using cached https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp36-cp36m-win_amd64.whl
Collecting tensorflow-tensorboard<0.2.0,>=0.1.0 (from tensorflow==1.3.0)
Exception:
Traceback (most recent call last):
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\commands\install.py", line 335, in run
    wb.build(autobuilding=True)
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\req\req_set.py", line 554, in _prepare_file
    require_hashes
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\req\req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\index.py", line 811, in get_page
    inst = cls(resp.content, resp.url, resp.headers)
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\index.py", line 731, in __init__
    namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
Error: Error 2 occurred installing packages into conda environment r-tensorflow
In addition: Warning message:
running command '"C:/Users/bbutcher/AppData/Local/CONTIN~1/ANACON~1/Scripts/activate" r-tensorflow && pip install --upgrade --ignore-installed "https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp36-cp36m-win_amd64.whl"' had status 2

Below is my session info:

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] keras_2.0.7.9009

loaded via a namespace (and not attached):
 [1] compiler_3.4.1        magrittr_1.5          R6_2.2.2              tools_3.4.1           whisker_0.3-2        
 [6] base64enc_0.1-3       curl_2.8.1            Rcpp_0.12.13          reticulate_1.2.0.9001 tensorflow_1.4       
[11] jsonlite_1.5          tfruns_0.9.1.9003

Any help would be greatly appreciated, thanks!

@jjallaire
Copy link
Member

It looks like there are some problems caused by tensorboard's dependency on an older version of html5lib. Here are some related discussions:

https://stackoverflow.com/questions/46499808/pip-throws-typeerror-parse-got-an-unexpected-keyword-argument-transport-enco

tensorflow/tensorboard#588

I'll continue investigating and hopefully come up with a way around this.

@jjallaire
Copy link
Member

It's still not 100% clear to me what triggers this error condition as I can't repro it. A couple of things to do:

  1. Let me know what version of Anaconda you are running. You can obtain this with:

    library(reticulate)
    conda_version()
    
  2. Try removing your conda environment and then re-installing with:

    library(reticulate)
    conda_remove("r-tensorflow")
    library(keras)
    install_keras()
    

@brandondbutcher
Copy link
Author

> library(reticulate)
> conda_version()
[1] "conda 4.3.27"
  1. Removing the conda environment and re-installing produced a new error:
> conda_remove("r-tensorflow")

Package plan for package removal in environment C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow:

The following packages will be REMOVED:

    asn1crypto:      0.22.0-py36h8e79faa_1     
    ca-certificates: 2017.08.26-h94faf87_0     
    cachecontrol:    0.12.3-py36hfe50d7b_0     
    certifi:         2017.7.27.1-py36h043bc9e_0
    cffi:            1.10.0-py36hae3d1b5_1     
    chardet:         3.0.4-py36h420ce6e_1      
    colorama:        0.3.9-py36h029ae33_0      
    cryptography:    2.0.3-py36h123decb_1      
    distlib:         0.2.5-py36h51371be_0      
    freetype:        2.8-vc14h17c9bdf_0         [vc14]
    h5py:            2.7.0-py36hfbe0a52_1      
    hdf5:            1.10.1-vc14hb361328_0      [vc14]
    html5lib:        0.999999999-py36ha09b1f3_0
    icc_rt:          2017.0.4-h97af966_0       
    idna:            2.6-py36h148d497_1        
    intel-openmp:    2018.0.0-hcd89f80_7       
    jpeg:            9b-vc14h4d7706e_1          [vc14]
    libpng:          1.6.32-vc14hce43e6c_2      [vc14]
    libtiff:         4.0.8-vc14h04e2a1e_10      [vc14]
    lockfile:        0.12.2-py36h0468280_0     
    mkl:             2018.0.0-h36b65af_4       
    msgpack-python:  0.4.8-py36h58b1e9d_0      
    numpy:           1.13.1-py36haf1bc54_2     
    olefile:         0.44-py36h0a7bdd2_0       
    openssl:         1.0.2l-vc14hcac20b0_2      [vc14]
    packaging:       16.8-py36ha0986f6_1       
    pillow:          4.2.1-py36hdb25ab2_0      
    pip:             9.0.1-py36hadba87b_3      
    progress:        1.3-py36hbeca8d3_0        
    pycparser:       2.18-py36hd053e01_1       
    pyopenssl:       17.2.0-py36h15ca2fc_0     
    pyparsing:       2.2.0-py36h785a196_1      
    pysocks:         1.6.7-py36h698d350_1      
    python:          3.6.2-h09676a0_15         
    pyyaml:          3.12-py36h1d1928f_1       
    requests:        2.18.4-py36h4371aae_1     
    scipy:           0.19.1-py36h7565378_3     
    setuptools:      36.5.0-py36h65f9e6e_0     
    six:             1.10.0-py36h2c0fdd8_1     
    urllib3:         1.22-py36h276f60a_0       
    vc:              14-h2379b0c_1             
    vs2015_runtime:  14.0.25123-hd4c4e62_1     
    webencodings:    0.5.1-py36h67c50ae_1      
    wheel:           0.29.0-py36h6ce6cde_1     
    win_inet_pton:   1.0.1-py36he67d7fd_1      
    wincertstore:    0.2-py36h7fe50ca_0        
    yaml:            0.1.7-vc14hb31d195_1       [vc14]
    zlib:            1.2.11-vc14h1cdd9ab_1      [vc14]
> library(keras)
> install_keras()
Creating r-tensorflow conda environment for TensorFlow installation...
Fetching package metadata .............
Solving package specifications: .

Package plan for installation in environment C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow:

The following NEW packages will be INSTALLED:

    asn1crypto:      0.22.0-py36h8e79faa_1     
    ca-certificates: 2017.08.26-h94faf87_0     
    cachecontrol:    0.12.3-py36hfe50d7b_0     
    certifi:         2017.7.27.1-py36h043bc9e_0
    cffi:            1.10.0-py36hae3d1b5_1     
    chardet:         3.0.4-py36h420ce6e_1      
    colorama:        0.3.9-py36h029ae33_0      
    cryptography:    2.0.3-py36h123decb_1      
    distlib:         0.2.5-py36h51371be_0      
    html5lib:        0.999999999-py36ha09b1f3_0
    idna:            2.6-py36h148d497_1        
    lockfile:        0.12.2-py36h0468280_0     
    msgpack-python:  0.4.8-py36h58b1e9d_0      
    openssl:         1.0.2l-vc14hcac20b0_2      [vc14]
    packaging:       16.8-py36ha0986f6_1       
    pip:             9.0.1-py36hadba87b_3      
    progress:        1.3-py36hbeca8d3_0        
    pycparser:       2.18-py36hd053e01_1       
    pyopenssl:       17.2.0-py36h15ca2fc_0     
    pyparsing:       2.2.0-py36h785a196_1      
    pysocks:         1.6.7-py36h698d350_1      
    python:          3.6.2-h09676a0_15         
    requests:        2.18.4-py36h4371aae_1     
    setuptools:      36.5.0-py36h65f9e6e_0     
    six:             1.10.0-py36h2c0fdd8_1     
    urllib3:         1.22-py36h276f60a_0       
    vc:              14-h2379b0c_1             
    vs2015_runtime:  14.0.25123-hd4c4e62_1     
    webencodings:    0.5.1-py36h67c50ae_1      
    wheel:           0.29.0-py36h6ce6cde_1     
    win_inet_pton:   1.0.1-py36he67d7fd_1      
    wincertstore:    0.2-py36h7fe50ca_0        

#
# To activate this environment, use:
# > activate r-tensorflow
#
# To deactivate an active environment, use:
# > deactivate
#
# * for power-users using bash, you must source
#

Determining latest release of TensorFlow...done
Installing TensorFlow...
Traceback (most recent call last):
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\Scripts\pip-script.py", line 6, in <module>
    from pip import main
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\__init__.py", line 28, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\vcs\subversion.py", line 9, in <module>
    from pip.index import Link
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\index.py", line 33, in <module>
    from pip._vendor import html5lib, requests, six
ImportError: cannot import name 'html5lib'
Error: Error 1 occurred installing packages into conda environment r-tensorflow
In addition: Warning message:
running command '"C:/Users/bbutcher/AppData/Local/CONTIN~1/ANACON~1/Scripts/activate" r-tensorflow && pip install --upgrade --ignore-installed "https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp36-cp36m-win_amd64.whl"' had status 1

I then uninstalled and re-installed Anaconda and replaced the html5lib folder as suggested in the stackoverflow post but ended up getting the same initial error.

@jjallaire
Copy link
Member

Yikes, I'm not at all sure how to troubleshoot this further. It looks like there is some conflict between Anaconda html5lib and the one that TensorFlow wants to use but I'm not sure what steps are required to circumvent the conflict.

@brandondbutcher
Copy link
Author

Very puzzling indeed. A similar error occurs with tfestimators as well. Hopefully someone can provide some insight here.

> devtools::install_github("rstudio/tfestimators")
> ibrary(tfestimators)
> install_tensorflow()
Using r-tensorflow conda environment for TensorFlow installation
Determining latest release of TensorFlow...done
Installing TensorFlow...
Traceback (most recent call last):
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\Scripts\pip-script.py", line 6, in <module>
    from pip import main
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\__init__.py", line 28, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\vcs\subversion.py", line 9, in <module>
    from pip.index import Link
  File "C:\Users\bbutcher\AppData\Local\CONTIN~1\ANACON~1\envs\r-tensorflow\lib\site-packages\pip\index.py", line 33, in <module>
    from pip._vendor import html5lib, requests, six
ImportError: cannot import name 'html5lib'
Error: Error 1 occurred installing packages into conda environment r-tensorflow
In addition: Warning message:
running command '"C:/Users/bbutcher/AppData/Local/CONTIN~1/ANACON~1/Scripts/activate" r-tensorflow && pip install --upgrade --ignore-installed "https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp36-cp36m-win_amd64.whl"' had status 1

@jjallaire
Copy link
Member

You could try manually installing 'html5lib' with:

library(reticulate)
conda_install("r-tensorflow", "html5lib")

I am totally flummoxed by this as I don't understand the vagaries of pip/conda packaging and dependencies.

@brandondbutcher
Copy link
Author

Oddly enough, I was able to get tensorflow up and running by uninstalling Anaconda and then re-installing.

install.packages("tensorflow")
library(tensorflow)
install_tensorflow()

After a clean install of Anaconda, the above worked just fine and I'm off and running with the tensorflow tutorials.

@jjallaire
Copy link
Member

Okay, that's great to hear! Perhaps this is something isolated to certain misconfigurations or bad states of Anaconda and we won't see much of it in the wild. Let's hope so!

@JianpingCAI
Copy link

I had exactly the same situation and error. Go back to Anaconda3-4.4.0 (instead of 5.0.0) solves the issue, though it is a temporary solution.

@ranalytics
Copy link

ranalytics commented Oct 19, 2017

Has anyone figured out how to solve this issue? I am having the same trouble with install_keras() as in the original post by @brandondbutcher. The root of the problem is definitely in the Python's html5lib package, but is there possibly a workaround?

@jjallaire
Copy link
Member

We did figure out the source of the problem and there is now a fix/workaround. See details here: #147

Note that underlying issue is an interaction between conda and tensorboard and it results is a corrupted pip for your anaconda installation. This means that you need to remove and re-install anaconda and then only after that run install_keras. Note also that the fix requires the development version of the keras package.

@ccrosetti
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants