How can I Integrate Python version 3 with .Net
I am Integrating Python script to .Net and I am using IronPython package that's available for .Net developers in Visual Studio. My Python code contains packages like face_recognition, glob, opencv. I am getting an error when I'am running this python script although the simple Python is running in PyCharm. Can anyone know what I am doing wrong? Please give me the answer that I should do.
These packages I am using and later I am using it by calling them:
import face_recognition
import cv2
import glob
video_capture = cv2.VideoCapture(0)
all_images = glob.glob('images/*.jpg')
And this is my Code which is in Visual Studio: (Making a Console App)
var py = Python.CreateEngine();
py.ExecuteFile("C:\Users\Hp\PycharmProjects\final_face\example.py");
Console.ReadLine();
And the error I am getting by the Visual Studio is:
Exception thrown: 'Microsoft.Scripting.SyntaxErrorException' in Microsoft.Scripting.dll
The program '[23408] PythonDotNet.exe' has exited with code 0 (0x0).
c# python .net opencv face-recognition
add a comment |
I am Integrating Python script to .Net and I am using IronPython package that's available for .Net developers in Visual Studio. My Python code contains packages like face_recognition, glob, opencv. I am getting an error when I'am running this python script although the simple Python is running in PyCharm. Can anyone know what I am doing wrong? Please give me the answer that I should do.
These packages I am using and later I am using it by calling them:
import face_recognition
import cv2
import glob
video_capture = cv2.VideoCapture(0)
all_images = glob.glob('images/*.jpg')
And this is my Code which is in Visual Studio: (Making a Console App)
var py = Python.CreateEngine();
py.ExecuteFile("C:\Users\Hp\PycharmProjects\final_face\example.py");
Console.ReadLine();
And the error I am getting by the Visual Studio is:
Exception thrown: 'Microsoft.Scripting.SyntaxErrorException' in Microsoft.Scripting.dll
The program '[23408] PythonDotNet.exe' has exited with code 0 (0x0).
c# python .net opencv face-recognition
are you using the same Python version for both the native (CPython) and IronPython interpreters? There are many differences between v2 and v3.
– Alexander Pope
Nov 10 '18 at 16:17
No, IronPython latest version is 2.7.9 and CPython is 3.6.6.
– M A K
Nov 19 '18 at 12:23
Then you found the problem, IronPython 3 is not ready for production, see github.com/IronLanguages/ironpython3
– Alexander Pope
Nov 19 '18 at 22:27
Instead of using IronPython you can execute the Python script in a command line and parse the output, see if this helps: stackoverflow.com/questions/206323/…
– Alexander Pope
Nov 19 '18 at 22:34
@AlexanderPope Thanks man your suggested link has my answer. I am answering to my question below.
– M A K
Nov 20 '18 at 8:17
add a comment |
I am Integrating Python script to .Net and I am using IronPython package that's available for .Net developers in Visual Studio. My Python code contains packages like face_recognition, glob, opencv. I am getting an error when I'am running this python script although the simple Python is running in PyCharm. Can anyone know what I am doing wrong? Please give me the answer that I should do.
These packages I am using and later I am using it by calling them:
import face_recognition
import cv2
import glob
video_capture = cv2.VideoCapture(0)
all_images = glob.glob('images/*.jpg')
And this is my Code which is in Visual Studio: (Making a Console App)
var py = Python.CreateEngine();
py.ExecuteFile("C:\Users\Hp\PycharmProjects\final_face\example.py");
Console.ReadLine();
And the error I am getting by the Visual Studio is:
Exception thrown: 'Microsoft.Scripting.SyntaxErrorException' in Microsoft.Scripting.dll
The program '[23408] PythonDotNet.exe' has exited with code 0 (0x0).
c# python .net opencv face-recognition
I am Integrating Python script to .Net and I am using IronPython package that's available for .Net developers in Visual Studio. My Python code contains packages like face_recognition, glob, opencv. I am getting an error when I'am running this python script although the simple Python is running in PyCharm. Can anyone know what I am doing wrong? Please give me the answer that I should do.
These packages I am using and later I am using it by calling them:
import face_recognition
import cv2
import glob
video_capture = cv2.VideoCapture(0)
all_images = glob.glob('images/*.jpg')
And this is my Code which is in Visual Studio: (Making a Console App)
var py = Python.CreateEngine();
py.ExecuteFile("C:\Users\Hp\PycharmProjects\final_face\example.py");
Console.ReadLine();
And the error I am getting by the Visual Studio is:
Exception thrown: 'Microsoft.Scripting.SyntaxErrorException' in Microsoft.Scripting.dll
The program '[23408] PythonDotNet.exe' has exited with code 0 (0x0).
c# python .net opencv face-recognition
c# python .net opencv face-recognition
edited Dec 13 '18 at 11:36
asked Nov 10 '18 at 12:18
M A K
255
255
are you using the same Python version for both the native (CPython) and IronPython interpreters? There are many differences between v2 and v3.
– Alexander Pope
Nov 10 '18 at 16:17
No, IronPython latest version is 2.7.9 and CPython is 3.6.6.
– M A K
Nov 19 '18 at 12:23
Then you found the problem, IronPython 3 is not ready for production, see github.com/IronLanguages/ironpython3
– Alexander Pope
Nov 19 '18 at 22:27
Instead of using IronPython you can execute the Python script in a command line and parse the output, see if this helps: stackoverflow.com/questions/206323/…
– Alexander Pope
Nov 19 '18 at 22:34
@AlexanderPope Thanks man your suggested link has my answer. I am answering to my question below.
– M A K
Nov 20 '18 at 8:17
add a comment |
are you using the same Python version for both the native (CPython) and IronPython interpreters? There are many differences between v2 and v3.
– Alexander Pope
Nov 10 '18 at 16:17
No, IronPython latest version is 2.7.9 and CPython is 3.6.6.
– M A K
Nov 19 '18 at 12:23
Then you found the problem, IronPython 3 is not ready for production, see github.com/IronLanguages/ironpython3
– Alexander Pope
Nov 19 '18 at 22:27
Instead of using IronPython you can execute the Python script in a command line and parse the output, see if this helps: stackoverflow.com/questions/206323/…
– Alexander Pope
Nov 19 '18 at 22:34
@AlexanderPope Thanks man your suggested link has my answer. I am answering to my question below.
– M A K
Nov 20 '18 at 8:17
are you using the same Python version for both the native (CPython) and IronPython interpreters? There are many differences between v2 and v3.
– Alexander Pope
Nov 10 '18 at 16:17
are you using the same Python version for both the native (CPython) and IronPython interpreters? There are many differences between v2 and v3.
– Alexander Pope
Nov 10 '18 at 16:17
No, IronPython latest version is 2.7.9 and CPython is 3.6.6.
– M A K
Nov 19 '18 at 12:23
No, IronPython latest version is 2.7.9 and CPython is 3.6.6.
– M A K
Nov 19 '18 at 12:23
Then you found the problem, IronPython 3 is not ready for production, see github.com/IronLanguages/ironpython3
– Alexander Pope
Nov 19 '18 at 22:27
Then you found the problem, IronPython 3 is not ready for production, see github.com/IronLanguages/ironpython3
– Alexander Pope
Nov 19 '18 at 22:27
Instead of using IronPython you can execute the Python script in a command line and parse the output, see if this helps: stackoverflow.com/questions/206323/…
– Alexander Pope
Nov 19 '18 at 22:34
Instead of using IronPython you can execute the Python script in a command line and parse the output, see if this helps: stackoverflow.com/questions/206323/…
– Alexander Pope
Nov 19 '18 at 22:34
@AlexanderPope Thanks man your suggested link has my answer. I am answering to my question below.
– M A K
Nov 20 '18 at 8:17
@AlexanderPope Thanks man your suggested link has my answer. I am answering to my question below.
– M A K
Nov 20 '18 at 8:17
add a comment |
2 Answers
2
active
oldest
votes
You are getting an error because that function is not what you want.
Create a new Console App Project called RunPython.csproj. In the main sub, write:
static void Main(string args)
var py = Python.CreateRuntime();
py.ExecuteFile();
After that, you can build your project to generate an ".exe" file. In Console or a shell, write:
RunPython.exe "C:UsersHpPycharmProjectsfinal_faceexample.py"
You can visit this site for more examples.
No it is not working man. It throwing an error and showing build failed in the Error List.
– M A K
Nov 19 '18 at 12:19
add a comment |
IronPython 3 is not ready for production so Instead of using IronPython you can execute the Python script in a command line and parse the output:
class Program
static void Main(string args)
Program p = new Program();
p.butPython();
public void butPython()
var hello = "Calling Python...";
Tuple<String, String> python = GoPython(@"C:UsersHPPycharmProjectsfinal_facefinal.py");
hello = python.Item1; // Show result.
Console.WriteLine(hello);
Console.ReadLine();
public Tuple<String, String> GoPython(string pythonFile, string moreArgs = "")
ProcessStartInfo PSI = new ProcessStartInfo();
PSI.FileName = "py.exe";
PSI.Arguments = string.Format(""0" 1", pythonFile, moreArgs);
PSI.CreateNoWindow = true;
PSI.UseShellExecute = false;
PSI.RedirectStandardError = true;
PSI.RedirectStandardOutput = true;
using (Process process = Process.Start(PSI))
using (StreamReader reader = process.StandardOutput)
string stderr = process.StandardError.ReadToEnd(); // Error(s)!!
string result = reader.ReadToEnd(); // What we want.
return new Tuple<String, String>(result, stderr);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238878%2fhow-can-i-integrate-python-version-3-with-net%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are getting an error because that function is not what you want.
Create a new Console App Project called RunPython.csproj. In the main sub, write:
static void Main(string args)
var py = Python.CreateRuntime();
py.ExecuteFile();
After that, you can build your project to generate an ".exe" file. In Console or a shell, write:
RunPython.exe "C:UsersHpPycharmProjectsfinal_faceexample.py"
You can visit this site for more examples.
No it is not working man. It throwing an error and showing build failed in the Error List.
– M A K
Nov 19 '18 at 12:19
add a comment |
You are getting an error because that function is not what you want.
Create a new Console App Project called RunPython.csproj. In the main sub, write:
static void Main(string args)
var py = Python.CreateRuntime();
py.ExecuteFile();
After that, you can build your project to generate an ".exe" file. In Console or a shell, write:
RunPython.exe "C:UsersHpPycharmProjectsfinal_faceexample.py"
You can visit this site for more examples.
No it is not working man. It throwing an error and showing build failed in the Error List.
– M A K
Nov 19 '18 at 12:19
add a comment |
You are getting an error because that function is not what you want.
Create a new Console App Project called RunPython.csproj. In the main sub, write:
static void Main(string args)
var py = Python.CreateRuntime();
py.ExecuteFile();
After that, you can build your project to generate an ".exe" file. In Console or a shell, write:
RunPython.exe "C:UsersHpPycharmProjectsfinal_faceexample.py"
You can visit this site for more examples.
You are getting an error because that function is not what you want.
Create a new Console App Project called RunPython.csproj. In the main sub, write:
static void Main(string args)
var py = Python.CreateRuntime();
py.ExecuteFile();
After that, you can build your project to generate an ".exe" file. In Console or a shell, write:
RunPython.exe "C:UsersHpPycharmProjectsfinal_faceexample.py"
You can visit this site for more examples.
edited Nov 10 '18 at 22:02
rm-
4,25622451
4,25622451
answered Nov 10 '18 at 17:49
D. Hurtado
816
816
No it is not working man. It throwing an error and showing build failed in the Error List.
– M A K
Nov 19 '18 at 12:19
add a comment |
No it is not working man. It throwing an error and showing build failed in the Error List.
– M A K
Nov 19 '18 at 12:19
No it is not working man. It throwing an error and showing build failed in the Error List.
– M A K
Nov 19 '18 at 12:19
No it is not working man. It throwing an error and showing build failed in the Error List.
– M A K
Nov 19 '18 at 12:19
add a comment |
IronPython 3 is not ready for production so Instead of using IronPython you can execute the Python script in a command line and parse the output:
class Program
static void Main(string args)
Program p = new Program();
p.butPython();
public void butPython()
var hello = "Calling Python...";
Tuple<String, String> python = GoPython(@"C:UsersHPPycharmProjectsfinal_facefinal.py");
hello = python.Item1; // Show result.
Console.WriteLine(hello);
Console.ReadLine();
public Tuple<String, String> GoPython(string pythonFile, string moreArgs = "")
ProcessStartInfo PSI = new ProcessStartInfo();
PSI.FileName = "py.exe";
PSI.Arguments = string.Format(""0" 1", pythonFile, moreArgs);
PSI.CreateNoWindow = true;
PSI.UseShellExecute = false;
PSI.RedirectStandardError = true;
PSI.RedirectStandardOutput = true;
using (Process process = Process.Start(PSI))
using (StreamReader reader = process.StandardOutput)
string stderr = process.StandardError.ReadToEnd(); // Error(s)!!
string result = reader.ReadToEnd(); // What we want.
return new Tuple<String, String>(result, stderr);
add a comment |
IronPython 3 is not ready for production so Instead of using IronPython you can execute the Python script in a command line and parse the output:
class Program
static void Main(string args)
Program p = new Program();
p.butPython();
public void butPython()
var hello = "Calling Python...";
Tuple<String, String> python = GoPython(@"C:UsersHPPycharmProjectsfinal_facefinal.py");
hello = python.Item1; // Show result.
Console.WriteLine(hello);
Console.ReadLine();
public Tuple<String, String> GoPython(string pythonFile, string moreArgs = "")
ProcessStartInfo PSI = new ProcessStartInfo();
PSI.FileName = "py.exe";
PSI.Arguments = string.Format(""0" 1", pythonFile, moreArgs);
PSI.CreateNoWindow = true;
PSI.UseShellExecute = false;
PSI.RedirectStandardError = true;
PSI.RedirectStandardOutput = true;
using (Process process = Process.Start(PSI))
using (StreamReader reader = process.StandardOutput)
string stderr = process.StandardError.ReadToEnd(); // Error(s)!!
string result = reader.ReadToEnd(); // What we want.
return new Tuple<String, String>(result, stderr);
add a comment |
IronPython 3 is not ready for production so Instead of using IronPython you can execute the Python script in a command line and parse the output:
class Program
static void Main(string args)
Program p = new Program();
p.butPython();
public void butPython()
var hello = "Calling Python...";
Tuple<String, String> python = GoPython(@"C:UsersHPPycharmProjectsfinal_facefinal.py");
hello = python.Item1; // Show result.
Console.WriteLine(hello);
Console.ReadLine();
public Tuple<String, String> GoPython(string pythonFile, string moreArgs = "")
ProcessStartInfo PSI = new ProcessStartInfo();
PSI.FileName = "py.exe";
PSI.Arguments = string.Format(""0" 1", pythonFile, moreArgs);
PSI.CreateNoWindow = true;
PSI.UseShellExecute = false;
PSI.RedirectStandardError = true;
PSI.RedirectStandardOutput = true;
using (Process process = Process.Start(PSI))
using (StreamReader reader = process.StandardOutput)
string stderr = process.StandardError.ReadToEnd(); // Error(s)!!
string result = reader.ReadToEnd(); // What we want.
return new Tuple<String, String>(result, stderr);
IronPython 3 is not ready for production so Instead of using IronPython you can execute the Python script in a command line and parse the output:
class Program
static void Main(string args)
Program p = new Program();
p.butPython();
public void butPython()
var hello = "Calling Python...";
Tuple<String, String> python = GoPython(@"C:UsersHPPycharmProjectsfinal_facefinal.py");
hello = python.Item1; // Show result.
Console.WriteLine(hello);
Console.ReadLine();
public Tuple<String, String> GoPython(string pythonFile, string moreArgs = "")
ProcessStartInfo PSI = new ProcessStartInfo();
PSI.FileName = "py.exe";
PSI.Arguments = string.Format(""0" 1", pythonFile, moreArgs);
PSI.CreateNoWindow = true;
PSI.UseShellExecute = false;
PSI.RedirectStandardError = true;
PSI.RedirectStandardOutput = true;
using (Process process = Process.Start(PSI))
using (StreamReader reader = process.StandardOutput)
string stderr = process.StandardError.ReadToEnd(); // Error(s)!!
string result = reader.ReadToEnd(); // What we want.
return new Tuple<String, String>(result, stderr);
answered Nov 20 '18 at 8:22
M A K
255
255
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238878%2fhow-can-i-integrate-python-version-3-with-net%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
are you using the same Python version for both the native (CPython) and IronPython interpreters? There are many differences between v2 and v3.
– Alexander Pope
Nov 10 '18 at 16:17
No, IronPython latest version is 2.7.9 and CPython is 3.6.6.
– M A K
Nov 19 '18 at 12:23
Then you found the problem, IronPython 3 is not ready for production, see github.com/IronLanguages/ironpython3
– Alexander Pope
Nov 19 '18 at 22:27
Instead of using IronPython you can execute the Python script in a command line and parse the output, see if this helps: stackoverflow.com/questions/206323/…
– Alexander Pope
Nov 19 '18 at 22:34
@AlexanderPope Thanks man your suggested link has my answer. I am answering to my question below.
– M A K
Nov 20 '18 at 8:17