kdpsingh / clinspacy

Clinical Natural Language Processing using spaCy, scispacy, and medspacy
Other
96 stars 19 forks source link

Cannot initialize clinspacy #11

Open athan-dial opened 3 years ago

athan-dial commented 3 years ago

I'm not having any success initializing clinspacy. It goes through the same sequence with and without the miniconda = FALSE argument. I've also tried to downgrade python to 3.6 to initial tutorial. Any idea how to get around this issue with Python version? Example of code below

> library(clinspacy)
> clinspacy_init(use_linker = TRUE)

Initializing clinspacy using clinspacy_init()...
SpaCy not found. Installing spaCy...
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
                                                                                       0:00,  5.16it/s]
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - spacy==2.3.0 -> python[version='>=3.6,<3.7.0a0|>=3.8,<3.9.0a0|>=3.7,<3.8.0a0']

Your python: python=3.9

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
kdpsingh commented 3 years ago

Thank you for the comment, and my apologies for the delay in getting back to you on this.

Because clinspacy wraps spacy, scispacy, and medspacy, we essentially have to juggle a bunch of version issues between dependencies. The only issue I did not control for in clinspacy was the Python version. By default, clinspacy uses the reticulate::install_miniconda() function to install the latest version.

Based on your output, it looks like the issue is that spacy 2.3.0 (the version used in clinspacy) only supports up to Python 3.8 and not Python 3.9 whereas reticulate::install_miniconda() appears to be installing version Python 3.9.

In the short-term, I would recommend uninstalling this version of miniconda and manually installing miniconda with Python 3.8 (available here: https://docs.conda.io/en/latest/miniconda.html). That should work.

In the medium-term, I'm going to look into how to enforce which version of miniconda is installed. It looks like although scispacy currently supports spacy 3.0, medspacy still requires spacy 2.3.

kdpsingh commented 3 years ago

It looks like reticulate will soon allow the miniconda URL to be specified as an option() within R.

https://github.com/rstudio/reticulate/commit/486f0a5968436231367a7521af6040464b172ff6

As soon as this version of reticulate lands on CRAN, I'll plan to update clinspacy with a way to install the correct version of miniconda.

kdpsingh commented 3 years ago

Actually, I discovered that the problem was with reticulate::conda_create(), which installs the latest version of Python (right now = 3.9) into the newly created conda environment regardless of which version of miniconda is installed.

Because spacy 2.3.0 (needed for compatibility with medspacy) only supports up to Python 3.8, this creates a problem.

This is now fixed on the GitHub version of clinspacy. By updating to a newer version of reticulate (>= 1.19), we can now specify which Python version is needed in conda_create(), so I've set this up to require Python 3.8.

To fix, run this:

reticulate::conda_remove('clinspacy')
remotes::install_github('ML4LHS/clinspacy')

Then, when you run clinspacy_init(), everything should work.

Please let me know if this fixes the issue, and I'll plan to send this version to CRAN.

rpittman188 commented 8 months ago

I know I'm a few years late, but have you found a solution to this that still works in the updated versions of everything? I still have issues because of space 2.3.0.

jarioss92 commented 7 months ago

Hi Karandeep, I have the same problem, could you please help me?

kdpsingh commented 7 months ago

I will try to fix in the next 1-2 weeks. I haven't touched my R package codebase in a while but I will come back to this. Thank you for the ping.