Greta not recognising existing pip and virtualenv installs


#1

Hi,

So I’m trying to run greta and TensorFlow from a university Ubuntu machine, and that machine already has pip and virtualenv and tensorflow installed, though not tensorflow-probability.

But whenever I try to run install_tensorflow() from within RStudio I get the error "Error: Prerequisites for installing TensorFlow not available.

Please install the following Python packages before proceeding: pip, virtualenv"

When I then try to run the greta “getting started” code it then tells me that I haven’t got tensorflow-probability installed, but that doesn’t explain why the install_tensorflow() function is complaining about not having pip and virtualenv.

I also tried setting up a virtual environment via pip according to the instructions on the TensorFlow site: https://www.tensorflow.org/install/pip

but when I passed the name “venv” into the install_tensorflow() function in greta it still came back with the same error about pip and virtualenv not being installed.

So now I’m thoroughly confused, and would greatly appreciate any suggestions.

Many thanks
Louise


#2

Hi Louise,

A long write up of the optimal way to install greta’s dependencies can be found here. Unfortunately at this stage we can’t simply rely on install_tensorflow :cry:

No real idea why the installer couldn’t see pip though - maybe something to do with your user privileges? The installer looks for pip in these locations: c("/usr/bin", "/usr/local/bin", path.expand("~/.local/bin")) maybe it can’t access them?

All the best!


#3

Hi Voltemand,

Thanks for your quick reply and suggestions. I’m thinking it’s to do with the fact I’m on a networked university computer, because I can’t find a file named pip in either the /usr/bin/ folder or the /usr/local/bin/ folder, so it’s not just about permissions – pip is definitely already installed, but it must have been installed to somewhere else.

I’ve got in touch with local ITS to ask if they can install tensorflow-probability, since they already installed tensorflow in the past.
Thanks
Louise


#4

Late to the show here, but in case it helps anyone else:

Short answer is this is something of a bug in reticulate, which assumes that pip is in one of the locations as @Voltemand lists above, rather than looking on the PATH (like a normal shell command would do). See: https://github.com/rstudio/reticulate/issues/499). Your venv path is probably not one of those (e.g. it may be in ~/.virtualenvs/r-tensorflow/bin, which is the default for the R tensorflow package, or/opt/venvor similar, anyway, not one of those three). As a user you probably can't symlink to/usr/local/bin`, but you could do:

ln -s $VENV_HOME/bin/virtualenv ~/.local/bin/virtualenv
ln -s $VENV_HOME/bin/pip ~/.local/bin/pip

where $VENV_HOME is wherever you configured your venv and then the installers should be okay. Still may be better to use py_install("tensorflow") etc though instead of install_tensorflow(envname="venv"), since install_tensorflow() nukes the existing venv and thus byebye virtualenv and pip links anyway.

You should also be able to just install the packages into your venv from the shell using pip install, which may be more robust than the R wrappers at this time.