Windows10下Anaconda环境添加Jupyter Notebook R内核遇Error code 127
Hey there, let's work through this R kernel installation issue together! That error about jupyter-client and exit code 127 is super common on Windows with Anaconda, and it almost always ties back to path mismatches or missing dependencies in your conda environment. Here's how to fix it step by step:
First, ensure your conda environment has jupyter-client installed
Open up Anaconda Prompt, activate the environment you use for Jupyter (if you're using the base environment, just runconda activate base), then install jupyter-client directly via conda:conda install jupyter-clientAfter installation, verify it works by running:
jupyter kernelspec --versionIf this outputs a version number instead of an error, you're halfway there.
If R still can't find jupyter, specify the full path manually
Sometimes R doesn't pick up the conda environment's jupyter executable automatically. Here's how to fix that:- In Anaconda Prompt, run
where jupyterto get the full path to your jupyter.exe file. It'll look something likeC:\Users\YourUsername\anaconda3\Scripts\jupyter.exe. - Launch R from the same Anaconda Prompt (just type
Rand hit enter—this ensures R uses the same environment variables as your conda setup). - Run the installspec command with the full jupyter path (use either double backslashes or single forward slashes for the path):
IRkernel::installspec(jupyter = "C:\\Users\\YourUsername\\anaconda3\\Scripts\\jupyter.exe") # Or use forward slashes: # IRkernel::installspec(jupyter = "C:/Users/YourUsername/anaconda3/Scripts/jupyter.exe")
- In Anaconda Prompt, run
For a more seamless setup, install R and IRkernel via conda
If you installed R separately (not through Anaconda), you might run into more path conflicts. The easiest fix here is to install R and IRkernel directly in your conda environment:conda install -c r r-irkernelOnce installed, launch R from Anaconda Prompt and run
IRkernel::installspec()—this should work without any errors.Final check
Restart Jupyter Notebook and look for the R kernel option in the "New" dropdown. If it's still not showing up, try restarting your computer to refresh environment variables—sometimes that's all it takes!
内容的提问来源于stack exchange,提问作者Tim Hargreaves

