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

Namespace conflict with python config package #1628

Closed
CarterDoud opened this issue Jun 27, 2024 · 1 comment · Fixed by #1629
Closed

Namespace conflict with python config package #1628

CarterDoud opened this issue Jun 27, 2024 · 1 comment · Fixed by #1629

Comments

@CarterDoud
Copy link

CarterDoud commented Jun 27, 2024

Greetings,

When trying to run Python code that uses the Python Package "config", a namespace error occurs. Python will import the config module that belongs to reticulate itself, rather than the top level package "config".

Here's a minimal example. The example assumes that you have a Python virtual environment set up called 'venv'. The example will attempt to install the config package as well.

`

library(reticulate)
reticulate::use_virtualenv('venv')
reticulate::py_install("config")
reticulate::py_config()
utils::sessionInfo()
import config
cfg = config.Config('config.cfg')

This example assumes a minimal 'config.cfg' such as this:

test: 'test'

The above code produces the following error:
Traceback (most recent call last): File "<string>", line 1, in <module> AttributeError: module 'config' has no attribute 'Config'

When other packages are imported, they are correctly loaded from the virtual environment. Is there a solution to avoid this namespace conflict?

Code very similar to this has been used as part of a project in the past and has successfully avoided the issue, but the exact solution is not known.

If I import the module in R using reticulate::import('config') the package is found correctly

@t-kalinowski
Copy link
Member

t-kalinowski commented Jun 28, 2024

Thanks for reporting! This should be fixed on main now. Please install the development version and try it out:

pak::pak("rstudio/reticulate")

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

Successfully merging a pull request may close this issue.

2 participants