'I am getting a Torch error when using the textEmbed() function in the Text Package in R
I am trying to run the textEmbed() function in R using the text package in text analysis. However, I keep on getting errors telling me I haven't installed torch package, which I already have installed.
The code that I am running is as follows:
library(text)
library(torch)
# transform text data into word embeddings
wordembeddings <- textEmbed(Language_based_assessment_data_8)
wordembeddings
The error message is as follows:
Error in py_run_file_impl(file, local, convert) : ModuleNotFoundError: No module named 'torch'
The traceback error message:-
5.
stop(structure(list(message = "ModuleNotFoundError: No module named 'torch'", call = py_run_file_impl(file, local, convert), cppstack = NULL), class = c("Rcpp::exception", "C++Error", "error", "condition")))
4.
py_run_file_impl(file, local, convert)
3.
py_run_file(file, local = FALSE, convert = convert)
2.
reticulate::source_python(system.file("python", "huggingface_Interface3.py", package = "text", mustWork = TRUE))
1.
textEmbed(Language_based_assessment_data_8)
Please help!
Solution 1:[1]
There has been some recent installation improvements for the text
-package. Try this:
library(text)
library(reticulate)
# Install text required python packages in a conda environment (with defaults).
text::textrpp_install()
# Show available conda environments.
reticulate::conda_list()
# Initialize the installed conda environment.
# save_profile = TRUE saves the settings so that you don't have to run textrpp_initialize() after restarting R.
text::textrpp_initialize(save_profile = TRUE)
# Test so that the text package work.
textEmbed("hello")
see also extended installation guidelines: http://www.r-text.org/articles/Extended_Installation_Guide.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gorp |