HydroSysPotsdam / Forester

Interactive and web-based visualization of decision trees.
GNU General Public License v3.0
4 stars 0 forks source link

python src/run.py returns error (but different to Issue #48) #49

Open lshydro opened 1 year ago

lshydro commented 1 year ago

I'm having the same problem as Issue #48 , as in python src/run.py returns an error, but I receive a different error message:

CMD output:

C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master>python src/run.py Error in .makeMessage(..., domain = domain) : 3 arguments passed to .Internal(gettext) which requires 2 Error in gettext(fmt, domain = domain, trim = trim) : 3 arguments passed to .Internal(gettext) which requires 2 R[write to console]: Error in gettext(fmt, domain = domain, trim = trim) : 3 arguments passed to .Internal(gettext) which requires 2

Traceback (most recent call last): File "src/run.py", line 6, in from forester import server File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\server.py", line 6, in from .api import API File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\api.py", line 13, in from .database import File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\database__init.py", line 16, in class Database: File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\database\init.py", line 25, in Database from .projects import create_project_from_files, create_project_from_vendor File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\database\projects.py", line 11, in from .. import parser File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\parser.py", line 21, in import rpy2.robjects as ro File "C:\tools\miniconda3\lib\site-packages\rpy2\robjects\init__.py", line 19, in import rpy2.robjects.functions File "C:\tools\miniconda3\lib\site-packages\rpy2\robjects\functions.py", line 12, in from rpy2.robjects import help File "C:\tools\miniconda3\lib\site-packages\rpy2\robjects\help.py", line 45, in quiet_require('tools') File "C:\tools\miniconda3\lib\site-packages\rpy2\robjects\help.py", line 41, in quiet_require ok = _eval(expr) File "C:\tools\miniconda3\lib\site-packages\rpy2\rinterfacelib\conversion.py", line 45, in cdata = function(args, **kwargs) File "C:\tools\miniconda3\lib\site-packages\rpy2\rinterface.py", line 817, in call raise embedded.RRuntimeError(_rinterface._geterrmessage()) rpy2.rinterface_lib.embedded.RRuntimeError: Error in gettext(fmt, domain = domain, trim = trim) : 3 arguments passed to .Internal(gettext) which requires 2

OS: Windows 10 Browser: expected Firefox, but did not start Python Version: 3.8.5

david-strahl commented 1 year ago

Do you have R installed? It should not be needed to install and run Forester (only for parsing R files) but maybe the library I used works differently than I anticipated.

Could you provide me the version of rpy2 that was installed when you installed the requirements?

I will try to recreate the bug and find a solution as soon als possible!

david-strahl commented 1 year ago

The problem is due to a missing PATH variable on Windows that prevents rpy2 from find the R library.

To resolve this issue, the following worked for me:

  1. Find your R installation and write down the path to the folders library and bin. For me, they are C:\Program Files\R\R-4.2.3\library, C:\Program Files\R\R-4.2.3\bin
  2. On the Windows taskbar, right-click the Windows icon and select System.
  3. In the Settings window, scroll down to Related Settings, click Advanced system settings.
  4. On the Advanced tab, click Environment Variables. Click New to create new environment variable.
  5. Add a variable with the name R_LIBRARY and add the path to the library folder.
  6. Add a variable with the name R_BIN and add the path to the bin folder.
  7. Close and re-open the command prompt.
  8. Re-run Forester

Sadly, this brings you back to the issue https://github.com/HydroSysPotsdam/Forester/issues/48 (at least for me). But we'll do baby steps to get there.

david-strahl commented 1 year ago

I pushed a fix for #48, too.

@lshydro When you re-clone Forester and fix the PATH variables it should now work. Could you please confirm this, so I can close this issue?

lshydro commented 1 year ago

Unfortunately still not working after I updated the environment variables. The error seems to be the same. My current rpy2 version is 3.5.10. Is this maybe a problem that rpy does not work with the newest R version (4.2.2)? Or that I have two R library path (.libPaths in R returns two paths)? But that should be fixed using the environment variable, right?

Error in .makeMessage(..., domain = domain) : 3 arguments passed to .Internal(gettext) which requires 2 Error in gettext(fmt, domain = domain, trim = trim) : 3 arguments passed to .Internal(gettext) which requires 2 R[write to console]: Error in gettext(fmt, domain = domain, trim = trim) : 3 arguments passed to .Internal(gettext) which requires 2

Traceback (most recent call last): File "src/run.py", line 6, in from forester import server File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\server.py", line 6, in from .api import API, load_database File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\api.py", line 13, in from .database import File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\database__init.py", line 16, in class Database: File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\database\init.py", line 25, in Database from .projects import create_project_from_files, create_project_from_vendor File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\database\projects.py", line 14, in from .. import parser File "C:\Users\stein\Nextcloud\Reviews\Internal\Forester-master\src\forester\parser.py", line 21, in import rpy2.robjects as ro File "C:\tools\miniconda3\lib\site-packages\rpy2\robjects\init__.py", line 19, in import rpy2.robjects.functions File "C:\tools\miniconda3\lib\site-packages\rpy2\robjects\functions.py", line 12, in from rpy2.robjects import help File "C:\tools\miniconda3\lib\site-packages\rpy2\robjects\help.py", line 45, in quiet_require('tools') File "C:\tools\miniconda3\lib\site-packages\rpy2\robjects\help.py", line 41, in quiet_require ok = _eval(expr) File "C:\tools\miniconda3\lib\site-packages\rpy2\rinterfacelib\conversion.py", line 45, in cdata = function(args, **kwargs) File "C:\tools\miniconda3\lib\site-packages\rpy2\rinterface.py", line 817, in call raise embedded.RRuntimeError(_rinterface._geterrmessage()) rpy2.rinterface_lib.embedded.RRuntimeError: Error in gettext(fmt, domain = domain, trim = trim) : 3 arguments passed to .Internal(gettext) which requires 2

david-strahl commented 1 year ago

Sorry to hear that. I installed both R-4.2.2 and rpy2 3.5.10 and got the same error as you described. Previously I used R-4.2.3. There seems to be something different between the two versions.

To solve it (at least for me), I added yet another PATH variable to the R home directory (C:\Program Files\R\R-4.2.2\) called R_HOME and then it worked. It also seems like for this combination of R and rpy2 the other PATH variables are not essential.

I will try to find a real solution that does not require tinkering with the system variables asap.

david-strahl commented 1 year ago

I pushed what I hope is the fix for this problem. The R-related submodule is now imported safely and Forester should still run even if there is an error. However, you then can not parse R files. I also included a fix for the PATH variable problem and on my Windows machine it seems to work without setting R_HOME manually. However, I am not sure whether this is generalizable. It may be the case that you still need to do it.