1
$\begingroup$

I would like to use the Keras & Tensorflow package for R in RStudio.

Everytime I use the command install_keras() or install_tensorflow(), I get the following error:

Collecting keras 
Could not fetch URL https://pypi.python.org/simple/keras/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Could not find a version that satisfies the requirement keras (from versions: )
No matching distribution found for keras

I discovered that every time I tried to install Keras within R, it created a virtualenv in the following directory (basically overwriting it):

/users/username/.virtualenvs/

Where it has Python version Python 2.7.10 (default, Jul 14 2015, 19:46:27). When I directly activate the virtualenv and try pip install keras, I receive the same error. I figured out on Stack Exchange that I could solve this issue by using pip install requests[security]. This seemed to fix the problem but nevertheless, R won't use it.

How can I fix this problem, realising that every time I use install_keras(), I overwrite the virtualenv and the same problem occurs? I even tried using the tensorflow URL directly, but I get the same error when it tries to install other important packages.

Important information:

  • MacOS: 10.10.5
  • R: 3.3.3

I'm new to this, so my apologies if I don't use the terminology correctly. I did manage to make Tensorflow & Keras work in Anaconda and using Jupyter, but I can't seem to make it work in R in that environment as well.

$\endgroup$
0
$\begingroup$

Please check that which pip you are using to install keras. It is possible that your pip may be pip3( will find libraries for python 3.x), while pip2 aka pip (will find libraries for python 2.x).

Keras is supported in python 2.7:

Tensorflow also, they promote use of python 3.x, you can checkout this tow download 2.7 compatible whl. tensorflow 2.7


You can check the pip version by executing below cammand from terminal.

pip --version

To find location of python/ pip use:

which pip
which python

I would personally suggest use python 3.6 and above. As for python 2.x and python 3.4, support is going to be end soon.

| improve this answer | |
$\endgroup$
  • $\begingroup$ My pip version is pip 9.0.1 from /Users/username/.virtualenvs/r-tensorflow/lib/python2.7/site-packages (python 2.7). I understand that I have to update this, but when I use the R command (install_keras or install_tensorflow), it will use the default pip for that virtualenv (which, as it overwrites, uses pip 9.0.1 again) $\endgroup$ – abcd Jun 20 '19 at 9:08
  • $\begingroup$ tensorflow.org/install/pip?lang=python2 follow this link, this explains everything. $\endgroup$ – MSS Jun 20 '19 at 9:10
  • $\begingroup$ I tried that link before. Tensorflow won't upgrade past tensorflow 1.1.0. $\endgroup$ – abcd Jun 20 '19 at 9:13
0
$\begingroup$

To Install tensorflow use this command including --User.

pip install --ignore-installed --upgrade --user tensorflow==2.0.1

Here 2.0.1 is the version of tensorflow.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.