Python - Numpy Library

I have Python 38 installed and I have numpy as well. When importing numpy I ran into two issues:

  1. No intellisense
  2. Fails to compile

I’ve included in the search path the path to my python location.

BTW, I am using the PythonNet implementation.

Thanks for your help.

Alex Iuspa

Hi Alex,

We tested the following scenario:

Installed Python 3.8.0 with the numpy package (pip install numpy). On our tests, if we set
CodeEnvironment.PythonPath to the installation of Python 3.8, the following script compiles and runs just fine:

import numpy as np

result = [[0,0,0],
[0,0,0],
[0,0,0]]

det = np.linalg.det(np.array(result))
print("det = " + str(det))

Could you please try our DebuggerIntegration sample for Python to see if it works for you? It uses embedded Python installation, however you can change it to use Python 3.8 instead by calling

CodeEnvironment.PythonPath = instead of SetupPython in this demo.

In the same demo, we use PythonNETParser, and the code completion for np does not work indeed.

We do support (partially) code completion for Python packages. For example, code completion for the following code will work:
import json
json.

However, numpy package has more complex structure that our parser does not handle yet. Fixing this issue is already on our to-do list.

BTW, you may consider using our LSP-based Python parser which can be initialized like this:
var parser = new Alternet.Syntax.Parsers.Lsp.Python.PythonParser();
parser.Workspace.ServerDeploymentOptions.Mode = Alternet.Syntax.Parsers.Lsp.ServerDeploymentMode.ApplicationDefined;
parser.Workspace.ServerDeploymentOptions.ApplicationDefinedServerDirectory = pythonPath;

We tested it, and It shows code completion for numpy in case we set pythonPath to Python 3.9, however, it does not work for Python 3.8 (both have the language server installed: pip install language-server).

Kind regards,
Dmitry

When I I use PythonNet I am able to set globlalitems and set references to custom dlls. by setting the codeEnvironment. How do accomplish that functionicality with

var parser = new Alternet.Syntax.Parsers.Lsp.Python.PythonParser();

Thanks,

Hi Alex,

Right now, this can not be achieved with the LSP Python parser, it does not know anything about .NET objects or types.

In the subsequent versions, we’re going to investigate how we can generate interface .py files for the .NET assemblies so features like code completion recognize .NET types.

Kind regards,
Dmitry

Is the same case when import sys? I dont ge tintellisense for sys module.

AI

Hi Alex,

The Sys module is not defined as .py file; therefore we do not parse it and do not provide code completion for it.

It should be possible to do what we’ve done for IronPython - we load standard IronPython modules such as DateTime, implemented in .NET, and provide code completion using reflection.

Kind regards,
Dmitry