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

installation issues in spacyr #236

Closed
alexstark001 opened this issue Jan 16, 2023 · 12 comments
Closed

installation issues in spacyr #236

alexstark001 opened this issue Jan 16, 2023 · 12 comments

Comments

@alexstark001
Copy link

I was not able to install the spacey package in r. I am getting the following error when initializing.

spacy_initialize()
Found 'spacy_condaenv'. spacyr will use this environment
Error in py_run_file_impl(file, local, convert) :
ModuleNotFoundError: No module named 'spacy'
Capture

@kbenoit
Copy link
Collaborator

kbenoit commented Jan 16, 2023

Can you supply any information on your system?

@Mayazure any ideas?

@JBGruber
Copy link
Collaborator

I was stuck on the solving environment part you show in your screenshot this morning. What solved it was to change python_version in spacy_install to the actual version displayed by reticulate::py_config()[["version"]]:

spacyr::spacy_install(python_version = reticulate::py_config()[["version"]])

Different system, different background (this was on Debian bullseye; you seem to be on Windows). But worth a try, I think.

@kbenoit
Copy link
Collaborator

kbenoit commented Jan 19, 2023

Thanks @JBGruber that's exactly the solution, or simply specifying your current version of Python as a string. This is an issue we have to address, since 3.6 is hardwired into spacy_install() as a default value.
e.g.

python_version = "3.6",

@amatsuo we discussed refreshing this a few months ago. I'm too time-poor at the moment to get lost in this (although I would love to do so). Maybe @Mayazure could address it?

@leodumont
Copy link

Same problem as @alexstark001 here.

I tried the solution posted by @JBGruber but no luck.

ss_spacyr

System infos :
Ubuntu 20.04.5
Python 3.8.10
R version 4.2.2 Patched (2022-11-10 r83330)
latest spacyr build installed from github

@amatsuo
Copy link
Collaborator

amatsuo commented Jan 24, 2023

@leodumont

What happens when you try to run spacy from your terminal?

In terminal, could you try the following and show the output in each step?

## activate the environment
conda activate spacy_condaenv
## check the python version
python --version
## also the path 
which python 
## start python
python

## in python
import spacy 

nlp = spacy.load("en_core_web_sm")

@chainsawriot
Copy link

chainsawriot commented May 10, 2023

I had the same problem. My solution is to build the conda environment myself (Ubuntu 22.04).

## remove the (obsolete) Python 3.6 environment
#conda env remove --name spacy_condaenv
## install the "recommended" version of Python
Rscript -e 'reticulate::conda_create("spacy_condaenv")'

## install spacy manually
conda install -n spacy_condaenv spacy -y  
conda activate spacy_condaenv
python -m spacy download en_core_web_sm 
conda activate base
require(spacyr)
spacy_initialize()
spacy_parse("I solved this by building my own conda environment.")

@marcozanotti
Copy link

marcozanotti commented May 31, 2023

Very same problem here on


R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0


The solution proposed by @JBGruber did not work, unfortunately. Instead, the solution proposed by @chainsawriot worked. I managed it completely through R using reticulate instead of using conda from cli. Here is my workaround

reticulate::conda_remove("spacy_condaenv")  
reticulate::conda_create("spacy_condaenv")  
reticulate::conda_install("spacy_condaenv", packages = "spacy")  
spacyr::spacy_download_langmodel(model = "en")    

Then proceeding as usual with the language initialization.

@MonicaDiLeo
Copy link

I had the same issue. The solution posted by @marcozanotti worked for me. Thanks!

@JBGruber
Copy link
Collaborator

JBGruber commented Sep 1, 2023

I rewrote spacy_install() from scratch. It's not in the repo yet, but there is a pull request that you can test:

# install packaged from fork
remotes::install_github("JBGruber/spacyr")

# install spaCy and initialize
library(spacyr)
spacy_install()
spacy_initialize()

# test
txt <- c(d1 = "spaCy is great at fast natural language processing.",
         d2 = "Mr. Smith spent two years in North Carolina.")

parsedtxt <- spacy_parse(txt)
parsedtxt

I also included a file for debugging and manual/custom installation that might be useful: https://github.com/JBGruber/spacyr/blob/master/installation.Rmd.

@MarianoRico
Copy link

MarianoRico commented Oct 5, 2023

Please, @amatsuo or @Mayazure, could you update the CRAN version with @JBGruber's reimplementation of spacy_install() ? I guess many people, besides me, is waiting for this major update.

@kbenoit
Copy link
Collaborator

kbenoit commented Oct 5, 2023

Should be by early next week. Adding tests and even building the documentation for spacyr is not trivial, but we're getting there soon!

@kbenoit
Copy link
Collaborator

kbenoit commented Dec 13, 2023

Solved in v1.3.

@kbenoit kbenoit closed this as completed Dec 13, 2023
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

9 participants