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

When I start jupyter with a script, RScript is automatically started and then an error is reported #1108

Open
luffyxue55 opened this issue Dec 24, 2024 · 0 comments

Comments

@luffyxue55
Copy link

luffyxue55 commented Dec 24, 2024

Hello,anybody!

I am using Windows 11 and installed RSoft 2020.03. In my own Python service, there is a script to start Jupyter. The script content is as follows:

:: Determine the default configuration file path
for /f "delims=" %%i in ('%python% -c "import jupyter_core.paths as jp; print(jp.jupyter_config_dir())"') do (
    set config_dir=%%i
)
set config_file=%config_dir%\jupyter_lab_config.py

:: Check if the configuration file already exists
if exist "%config_file%" (
    echo Deleting existing configuration file: %config_file%
    del "%config_file%"
)

:: Generate Jupyter Lab configuration file and capture the output
echo Generating Jupyter Lab configuration file...
for /f "delims=" %%i in ('%python% -m jupyter lab --generate-config 2^>^&1') do (
    echo %%i
    echo %%i | find "Writing default config to:" >nul
    if !errorlevel! equ 0 (
        for /f "tokens=*" %%j in ("%%i") do (
            set "config_file=%%j"
        )
    )
)

:: Extract the actual path from the output line
set "config_file=%config_file:Writing default config to: =%"
echo Configuration file path: %config_file%

:: Trim leading and trailing spaces
for /f "tokens=* delims= " %%a in ("%config_file%") do set config_file=%%a
echo Trimmed configuration file path: %config_file%

:: Check if the configuration file was found
if "%config_file%"=="" (
    echo Failed to generate Jupyter Lab configuration file.
    exit /b 1
)

:: Modify the configuration file
if exist "%config_file%" (
    echo Modifying the configuration file...
    (for /f "usebackq delims=" %%i in ("%config_file%") do (
        set "line=%%i"
        if "%%i"=="# c.ServerApp.token = '<DEPRECATED>'" (
            echo c.ServerApp.token = ""
        ) else (
            echo !line!
        )
    )) > "%config_file%.tmp"
    move /y "%config_file%.tmp" "%config_file%"
    echo Configuration file modified successfully.
) else (
    echo Configuration file not found: %config_file%
    exit /b 1
)

:: Install the IPython kernel with the specified name
echo Installing IPython kernel...
%python% -m ipykernel install --user --name=%pname% --display-name=%pname%
if errorlevel 1 (
    echo Failed to install IPython kernel.
    exit /b 1
)
echo IPython kernel installed successfully.

When I run the script, a pop-up window of RScript will pop up and an error will be reported.
RScript-error

After clicking Confirm, the following prompt will appear in the console where the script is running:

[W 2024-12-24 14:42:50.684 ServerApp] Failed to fetch commands from language server spec finder `r-languageserver`:
    Command '['D:\\Synopsys\\PhotonicSolutions\\2020.03\\RSoft\\bin\\Rscript.EXE', '-e', "cat(system.file(package='languageserver'))"]' returned non-zero exit status 34.
Traceback (most recent call last):
  File "D:\...\lib\site-packages\jupyter_lsp\manager.py", line 269, in _autodetect_language_servers
    if not spec_finder_from_base.is_installed(self):
  File "D:\...\lib\site-packages\jupyter_lsp\specs\utils.py", line 45, in is_installed
    check_result = check_output([cmd, *self.is_installed_args]).decode(
  File "D:\...\lib\subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "D:\...\lib\subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['D:\\Synopsys\\PhotonicSolutions\\2020.03\\RSoft\\bin\\Rscript.EXE', '-e', "cat(system.file(package='languageserver'))"]' returned non-zero exit status 34.
[I 2024-12-24 14:42:50.737 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server

My environment package does not have any R language related content, which can be confirmed by adding the following output to the script:

%python% -m jupyter --paths
echo Listing installed Jupyter kernels...
%python% -m jupyter kernelspec list --json
set R
echo Listing Jupyter Lab extentions...
%python% -m jupyter labextension list
echo Listing Jupyter Servers...
%python% -m jupyter server list

I tried to delete the RSoft related content in the environment variable Path, and the error no longer appeared, but I am not sure whether this change has any effect on the use of RSoft.
Is there any other way?

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

1 participant