Jupyter中SASpy的SAS内核不可见,如何手动注册刷新?
It sounds like your SAS kernel installation didn’t properly register with Jupyter—this is a common issue, but easy to fix manually. Here’s how to get it up and running:
First, Confirm the SAS Kernel is Installed
First, let’s make sure the sas_kernel package is actually present on your system. Open Command Prompt or PowerShell and run:
pip show sas_kernel
Look for the Location line in the output—this tells you where the package is stored (e.g., C:\ProgramData\Anaconda3\Lib\site-packages\sas_kernel).
Option 1: Use Jupyter’s Built-in Kernelspec Command
This is the most straightforward method:
- From the
Locationpath above, navigate to thekernelspecsubfolder. For example, if your location isC:\ProgramData\Anaconda3\Lib\site-packages\sas_kernel, the full path to kernelspec would beC:\ProgramData\Anaconda3\Lib\site-packages\sas_kernel\kernelspec. - Run this command to register the kernel (replace the path with your actual kernelspec folder):
jupyter kernelspec install --user "C:\ProgramData\Anaconda3\Lib\site-packages\sas_kernel\kernelspec"
The --user flag ensures it’s installed for your account (avoids system-wide permission issues).
Option 2: Manually Copy the Kernel Files
If the command above doesn’t work, you can copy the files directly to Jupyter’s kernel directory:
- Go to your Jupyter kernels folder (from your
jupyter kernelspec listoutput, this isC:\ProgramData\Anaconda3\share\jupyter\kernels). - Create a new folder here named
sas. - Copy all files from the
kernelspecfolder of yoursas_kernelinstallation (from the Location path) into this newsasfolder.
Option 3: Build the Kernel Config from Scratch
If the first two options fail, you can create the kernel configuration manually:
- In the Jupyter kernels folder (
C:\ProgramData\Anaconda3\share\jupyter\kernels), make a new folder calledsas. - Inside that folder, create a file named
kernel.jsonwith this content:
{ "argv": ["python", "-m", "sas_kernel", "-f", "{connection_file}"], "display_name": "SAS", "language": "sas" }
Verify and Restart
After completing any of these steps:
- Run
jupyter kernelspec listagain—you should now see the SAS kernel listed. - Restart your Jupyter Notebook or Lab instance. The SAS kernel should now appear in the kernel selection dropdown.
Quick Troubleshooting Tip
If you’re using a conda environment, make sure you activate it first before running any of these commands. Also, if the kernel still doesn’t show up, double-check that the python path in kernel.json points to your Anaconda Python executable (e.g., C:\ProgramData\Anaconda3\python.exe instead of just python if there’s a path conflict).
内容的提问来源于stack exchange,提问作者cs0815

