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

Is there a way to change encoding py_load_object()? #542

Closed
maksymiuks opened this issue Jul 8, 2019 · 2 comments
Closed

Is there a way to change encoding py_load_object()? #542

maksymiuks opened this issue Jul 8, 2019 · 2 comments

Comments

@maksymiuks
Copy link

maksymiuks commented Jul 8, 2019

Hello.

I have a problem with loading pickle file created under python 2.7. When I try to load it via py_load_object() in env with python 3.7 i get error:

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xcb in position 0: ordinal not in range(128)

is there a way to overcome it? (Other than using python 2.7 env)

@kevinushey
Copy link
Collaborator

The py_load_object() function is pretty simple:

> reticulate:::py_load_object
function(filename, pickle = "pickle") {
  builtins <- import_builtins()
  pickle <- import(pickle)
  handle <- builtins$open(filename, "rb")
  on.exit(handle$close(), add = TRUE)
  pickle$load(handle)
}

Perhaps we could augment the function to accept other arguments that can be passed down to pickle$load().

@maksymiuks
Copy link
Author

It willl much appreciated

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

2 participants