Open Regenhardt opened 6 months ago
I followed https://github.com/dotnet/interactive/blob/HEAD/docs/jupyter-in-polyglot-notebooks.md and it worked for me. If you have already tried that, may be try the following in the .dip file and see if then python shows up as a code option.
This indeed helped me fix an adjacent problem, terminal not recognizing python. Had to disable the python app execution aliases in windows settings.
Unfortunately this did not fix vscode not finding python.
Terminal:
> python --version
Python 3.11.7
VSCode dib file:
> #!connect jupyter --kernel-name pythonkernel --kernel-spec python3
The #!connect jupyter feature is in preview. Please report any feedback or issues at https://github.com/dotnet/interactive/issues/new/choose.
Error: System.ArgumentException: KernelSpec python3 not found
at Microsoft.DotNet.Interactive.Jupyter.ZMQ.JupyterConnection.CreateKernelConnectionAsync(String kernelSpecName) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Jupyter\ZMQ\JupyterConnection.cs:line 47
at Microsoft.DotNet.Interactive.Jupyter.JupyterKernelConnector.CreateKernelAsync(String kernelName) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Jupyter\JupyterKernelConnector.cs:line 27
at Microsoft.DotNet.Interactive.Jupyter.ConnectJupyterKernelCommand.ConnectKernelsAsync(KernelInvocationContext context, InvocationContext commandLineContext) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Jupyter\ConnectJupyterKernelCommand.cs:line 72
at Microsoft.DotNet.Interactive.CompositeKernel.<>c__DisplayClass21_0.<<AddKernelConnector>b__0>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\CompositeKernel.cs:line 271
--- End of stack trace from previous location ---
at System.CommandLine.NamingConventionBinder.CommandHandler.GetExitCodeAsync(Object returnValue, InvocationContext context)
at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<<AddMiddleware>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Invocation.InvocationPipeline.<InvokeAsync>g__FullInvocationChainAsync|2_0(InvocationContext context)
at System.CommandLine.Parsing.ParseResultExtensions.InvokeAsync(ParseResult parseResult, IConsole console)
at Microsoft.DotNet.Interactive.Commands.DirectiveCommand.InvokeAsync(KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Commands\DirectiveCommand.cs:line 33
at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Kernel.cs:line 330
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<BuildPipeline>b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 60
at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 41
ms-toolsai.jupyter: v2023.11.1100101639
Are you using anaconda?
No, no virtual environments. Haven't installed anaconda here.
I have the same issue and I'm using miniconda which comes with a Python version 3.11.5. Also I don't have conda or python in the PATH env variable.
Doesn't mini onda come with default environment as root or base?
it does yes, it's called "base", and it's not complaining about that, it's complaining about the KernelSpec: "KernelSpec python3 not found"
can you run jupyter kernelspec list
and see what are the kernel specs and share the paths?
Good question, you made me go down the rabbit hole and figured out i was missing the iPython package. Thanks! :) All is well now, I'm able to run Python code from the .NET Interactive kernel.
@Regenhardt what do you see if you run the jupyter kernelspec list
command?
I get jupyter : The term 'jupyter' is not recognized as the name of a cmdlet, function, script file, or operable program.[...]
.
I installed/upgraded the notebook
package, pip list
includes notebook 7.0.7
(previously it was 7.0.1).
python/pip work, ipynb works too. PATH contains both Python\
and Python\Scripts\
. What am I missing?
I get
jupyter : The term 'jupyter' is not recognized as the name of a cmdlet, function, script file, or operable program.[...]
.I installed/upgraded the
notebook
package,pip list
includesnotebook 7.0.7
(previously it was 7.0.1). python/pip work, ipynb works too. PATH contains bothPython\
andPython\Scripts\
. What am I missing?
I usually install Jupyter using pip3 install jupyterlab
can you try that?
if the Jupyter command is not resolved it means Jupyter server is not installed and you don't have kernel spec available
Doing that results in a whole lot of "Requirement already satisfied" messages, the first being:
Requirement already satisfied: jupyterlab in e:\programs\python\lib\site-packages (4.0.10)
I'm not sure of what I'm doing wrong here. I have the same issue. I am using VSCode. I have both the Jupyter and the Polyglot extensions. I have dotnet-interactive running with with .Net 8 Runtime and SDK
#!connect jupyter --kernel-name pythonkernel --conda-env ai_course --kernel-spec ai_course
I get this with a long stacktrace
Error: System.ArgumentException: KernelSpec ai_course not found
at Microsoft.DotNet.Interactive.Jupyter.ZMQ.JupyterConnection.CreateKernelConnectionAsync(String kernelSpecName) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Jupyter\ZMQ\JupyterConnection.cs:line 47
On a conda info I get the following:
active environment : ai_course
active env location : /Users/gabor.konstanzer/miniconda3/envs/ai_course
shell level : 1
user config file : /Users/gabor.konstanzer/.condarc
populated config files :
conda version : 24.1.2
conda-build version : not installed
python version : 3.12.1.final.0
solver : libmamba (default)
virtual packages : __archspec=1=m1
__conda=24.1.2=0
__osx=13.5.2=0
__unix=0=0
base environment : /Users/gabor.konstanzer/miniconda3 (writable)
conda av data dir : /Users/gabor.konstanzer/miniconda3/etc/conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/osx-arm64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/osx-arm64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /Users/gabor.konstanzer/miniconda3/pkgs
/Users/gabor.konstanzer/.conda/pkgs
envs directories : /Users/gabor.konstanzer/miniconda3/envs
/Users/gabor.konstanzer/.conda/envs
platform : osx-arm64
user-agent : conda/24.1.2 requests/2.31.0 CPython/3.12.1 Darwin/22.6.0 OSX/13.5.2 solver/libmamba conda-libmamba-solver/23.12.0 libmambapy/1.5.3
UID:GID : 503:20
netrc file : None
offline mode : False
On jupyter kernelspec list I get the following: (I ran the dotnet-interactive jupyter install once)
Available kernels:
python3 /Users/gabor.konstanzer/miniconda3/envs/ai_course/share/jupyter/kernels/python3
.net-csharp /Users/gabor.konstanzer/Library/Jupyter/kernels/.net-csharp
.net-fsharp /Users/gabor.konstanzer/Library/Jupyter/kernels/.net-fsharp
.net-powershell /Users/gabor.konstanzer/Library/Jupyter/kernels/.net-powershell
ai_course /Users/gabor.konstanzer/Library/Jupyter/kernels/ai_course
VSCode finds the ai_course kernel. I can run python with it in another notebook, It just doesn't appear as a language when set to .NET Interactive kernel, nor can it connect with the magic connect command. Any Idea what could be missing?
I just went thru solving this error...for me I had to ensure the following:
%localappdata%\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts
;.PY
Hope that helps!
@webteckie thank you for such a detailed fix! This will be useful for other users too.
The package and version I'm asking about:
.NET Interactive
© 2020 Microsoft Corporation
Version: 1.0.461101+09b2630eed4bf45ad5c843caa3420ad14fbcd596
Library version: 1.0.0-beta.23611.1+09b2630eed4bf45ad5c843caa3420ad14fbcd596
Build date: 2023-12-19T16:00:34.1381822Z
https://github.com/dotnet/interactive
Question
I love the dib format for being great with git. The readme says Python even supports variable sharing.
How do I use python in a dib file? The language list in the bottom right corner of the cell doesn't contain python. I can only use an
ipynb
file with the python kernel, but the .NET Interactive kernel does not offer python to me.I currently have .NET 8 and Python 3.11.4 installed.
Cell kernel list:
![image](https://github.com/dotnet/interactive/assets/10476293/392c40be-ca70-45d4-9eaa-0aa2f53646a9)