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

reticulate doesn't find python (using steps in the documentation) #637

Closed
jgbradley1 opened this issue Nov 8, 2019 · 5 comments
Closed

Comments

@jgbradley1
Copy link

I have tried multiple ways to install and use reticulate. I believe the README instructions are wrong. I'm using the latest version of reticulate on CRAN. To keep a clean environment, I've been trying to install and use it inside a docker container first.

docker run -it ubuntu

apt-get update && apt-get upgrade -y
apt-get install -y r-base python3
R
> install.packages("reticulate")
> library(reticulate)
> use_python("/usr/bin/python3", required=T)
> os <- import("os")
Error in initialize_python(required_module, use_environment) :
  Python shared library not found, Python bindings not loaded.

Is there something I'm missing? I've seen references to building python from source and passing a shared flag. Does this mean people must build python from source to use reticulate or will reticulate work with standard python binaries installed by linux package managers?

@skeydan
Copy link

skeydan commented Nov 8, 2019

Hi,

no, there is absolutely no need to compile Python from source. Can you try - in a fresh R session - what is returned by

reticulate::py_discover_config()

@kevinushey
Copy link
Collaborator

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

This seems to imply that you have a version of Python installed that was not compiled with a shared library. It seems reticulate is discovering and preferring that Python installation, but is unable to load it.

@jgbradley1
Copy link
Author

Can you try - in a fresh R session - what is returned by

reticulate::py_discover_config()

When I run the following order of commands inside a docker container, I get the same error message:

docker run -it ubuntu

> apt-get update && apt-get upgrade -y
> apt-get install -y r-base python3
> R
> install.packages("reticulate")
> library(reticulate)
> reticulate::py_discover_config()
python:         /usr/bin/python3
libpython:      [NOT FOUND]
pythonhome:     /usr:/usr
version:        3.6.8 (default, Oct  7 2019, 12:59:55)  [GCC 8.3.0]
numpy:           [NOT FOUND]
> os <- import("os")
Error in initialize_python(required_module, use_environment) :
  Python shared library not found, Python bindings not loaded.
> quit() # restart R session
> R
> library(reticulate)
> reticulate::py_discover_config()
python:         /usr/bin/python3
libpython:      [NOT FOUND]
pythonhome:     /usr:/usr
version:        3.6.8 (default, Oct  7 2019, 12:59:55)  [GCC 8.3.0]
numpy:           [NOT FOUND]
> os <- import("os")
Error in initialize_python(required_module, use_environment) :
  Python shared library not found, Python bindings not loaded.

@jgbradley1
Copy link
Author

I figured out the problem after finding this issue. python3-dev was needed. A full working installation of reticulate is the following:

docker run -it ubuntu

> apt-get update && apt-get upgrade -y
> apt-get install -y r-base python3 python3-dev python3-pip python3-venv
> R
> install.packages("reticulate")
> library(reticulate)
> reticulate::py_discover_config()
python:         /usr/bin/python3
libpython:      /usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so
pythonhome:     /usr:/usr
version:        3.6.8 (default, Oct  7 2019, 12:59:55)  [GCC 8.3.0]
numpy:           [NOT FOUND]
> py_install("pandas") # install another python package as a test
> pandas <- import("pandas")

@ferroao
Copy link

ferroao commented Feb 11, 2021

I found I needed pip3 install numpy in stack

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

4 participants