Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python shared library not found, Python bindings not loaded. in RStudio on Mac

Tags:

r

keras

rstudio

I have seen this question answered for issues in Windows but haven't seen any solution for a Mac.

After installing keras like:

devtools::install_github("rstudio/keras")
library(keras)
install_keras()

I get the error when running:

library(keras)
mnist <- dataset_mnist()

>> Error in initialize_python(required_module, use_environment) : 
  Python shared library not found, Python bindings not loaded.

I have tried the following:

use_python("/Users/me/anaconda3/bin/python3.7", required = TRUE)
use_virtualenv("~/MyFolder/.venv/")
use_python("~/MyFolder/.venv/bin/python")

But haven't been successful, I saw some suggestions about wrong python installation but it shouldn't be it in my case. i have installed python 3.7.5 with Anaconda

=> python --version
Python 3.7.5

I'm on macOS Catalina Version 10.15.1 in RStudio, Version 1.2.5019. Does anyone have any solution?

like image 721
mprachar Avatar asked Nov 04 '19 11:11

mprachar


People also ask

Why can’t I deploy Python content to RStudio connect?

You may encounter the following error when deploying Python content to RStudio Connect: A workaround is to downgrade to virtualenv 16.1.0 and remove the associated Python environments in /var/lib/rstudio-connect/python-environments by running the following commands: where X.Y.Z is the version of Python you are using.

How do I install Python on R studio?

If you are working on your local machine, you can install Python from Python.org or Anaconda. If you are working on a server with RStudio Workbench (previously RStudio Server Pro), your administrator can install a system-wide version of Python, or you can install Python in your home directory from Python.org or Anaconda.

Why is my Jupyter Notebook not generating reports in RStudio connect?

This error will usually manifest by a Jupyter Notebook in Connect not having the dependencies you expect from the development environment. You can confirm this by adding the following lines as part of the notebook and generating the report again in RStudio Connect.

What happens if I install Python from source?

Installing Python from source will result in a standalone Python environment that is separate from the system/framework installation of Python that won't be affected when you update system packages.


2 Answers

This is a old thread, but just wanted to say for anyone that finds this that installing the python-dev package for whatever version of python you're using may work. I was using python3.8, so I installed python3.8-dev

like image 92
James Ronald Avatar answered Oct 23 '22 18:10

James Ronald


I had same problem with OSX. Found solution by configuring python virtual environment to use python3

library(reticulate)
use_python("/usr/local/bin/python3")
like image 31
jkm Avatar answered Oct 23 '22 18:10

jkm