1

I am using the Azure ML Notebook with R kernel and reticulate package is installed with version 1.25. When I run the following code:

library(reticulate)
Sys.which("python")

It gives the output as python: '/usr/bin/python' and so, I have used use_python("/usr/bin/python") but while using the py_config(), it gives me the following error:

Error in py_initialize(config$python, config$libpython, config$pythonhome, : PyException_SetTraceback - /usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so: undefined symbol: PyException_SetTraceback
Traceback:

1. py_config()
2. ensure_python_initialized()
3. initialize_python(required_module, use_environment)
4. tryCatch({
 .     oldpythonpath <- Sys.getenv("PYTHONPATH")
 .     newpythonpath <- Sys.getenv("RETICULATE_PYTHONPATH", unset = paste(config$pythonpath, 
 .         system.file("python", package = "reticulate"), sep = .Platform$path.sep))
 .     local({
 .         Sys.setenv(PYTHONPATH = newpythonpath)
 .         on.exit(Sys.setenv(PYTHONPATH = oldpythonpath), add = TRUE)
 .         py_initialize(config$python, config$libpython, config$pythonhome, 
 .             config$virtualenv_activate, config$version >= "3.0", 
 .             interactive(), numpy_load_error)
 .     })
 . }, error = function(e) {
 .     Sys.setenv(PATH = oldpath)
 .     if (is.na(curr_session_env)) {
 .         Sys.unsetenv("R_SESSION_INITIALIZED")
 .     }
 .     else {
 .         Sys.setenv(R_SESSION_INITIALIZED = curr_session_env)
 .     }
 .     stop(e)
 . })
5. tryCatchList(expr, classes, parentenv, handlers)
6. tryCatchOne(expr, names, parentenv, handlers[[1L]])
7. value[[3L]](cond)

Can anyone please help me to resolve this error. Any help would be appreciated.

ankit
  • 277
  • 1
  • 4
  • 25

1 Answers1

0

In Python 3 exceptions come equipped with a handy __traceback__ attribute. In Python 2 you need import the traceback module so I believe !pip install traceback within your notebook will resolve the issue you're experiencing. You can also drop into a terminal session and pip install traceback

See: https://techcommunity.microsoft.com/t5/educator-developer-blog/installing-python-packages-to-azure-notebooks/ba-p/379371 for detailed instructions on installing python packages in Azure ML notebooks.

br00t
  • 1,440
  • 8
  • 10
  • Hi, According to https://stackoverflow.com/questions/67552271/pip-error-no-module-named-traceback-couldnt-find-a-version-that-satisfies-the , traceback is not available on `pip`, so I have installed `traceback2` but still getting the same error. Could you please help ? – ankit Oct 14 '22 at 04:25
  • Resolved the issue using https://stackoverflow.com/questions/54447207/how-to-update-python-2-7-to-3-in-terminal – ankit Oct 14 '22 at 04:39