pyqt, matplotlib, multiprocessing comaptibility in windows
See original GitHub issueEnvironment
- Pythonnet version: 2.3
- Python version: 3.6
- Operating System: windows 10
Details
-
Describe what you were trying to get done.
I used the console example code in the pythonnet, and modified it a little bit to test the capabilities. Please see the code below:
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Python.Runtime;
namespace Python.Runtime
{
/// <summary>
/// Example of Embedding Python inside of a .NET program.
/// </summary>
/// <remarks>
/// It has similar functionality to doing `import clr` from within Python, but this does it
/// the other way around; That is, it loads Python inside of .NET program.
/// See https://github.com/pythonnet/pythonnet/issues/358 for more info.
/// </remarks>
public sealed class PythonConsole
{
static void Main(string[] args)
{
using (Py.GIL())
{
dynamic np = Py.Import("numpy");
dynamic plt = Py.Import("matplotlib.pyplot");
dynamic exp = Py.Import("pyqtgraph.examples");
Console.WriteLine(np.cos(np.pi * 2));
plt.plot(np.cos(np.pi * 2));
exp.run();
dynamic mp = Py.Import("ProcessIDTest");
Console.WriteLine(2);
mp.main();
Console.WriteLine(3);
}
}
}
}
Also the python code named ProcessIDTest.py:
from multiprocessing import Process
import os, time
def f(name):
print('Inside f.')
#plt.plot([1,2]);
#plt.show();
def main():
for i in range(2):
p = Process(target=f, args=('bob' +str(i),));
#p.start();
#p.join()
print('Main function executed.')
if __name__ == '__main__':
#main();
- What commands did you run to trigger this issue? If you can provide a If you run the code directly in vs2017, the following error was given, which is related to pyqt.
This application failed to start because it could not find or load the Qt platform plugin "windows"
in "". Reinstalling the application may fix this problem.
Fatal Python error: auto-releasing thread-state, but no thread-state for this thread.
I already tried reinstall my python and it’s still the same problem. Also I tested all the matplotlib backends, with only TkAgg working fine. Pyqt, tested with pyqtgraph, aslo did n’t work in PythonEngine as well. The same error was produced.
I also tested the multiprocessing in embedded python. If I start a child process, it will basically make my c# program looping, with more and more nPython.exe spawned. If you do not start it, everything works fine (like the code below).
for i in range(2):
p = Process(target=f, args=('bob' +str(i),));
#p.start();
#p.join()
For my project, what I need are the following packages: pyqt, matplotlib, pydaqmx, multiprocessing, pyglet. If you could let me know any news related to their compatibility, that would be awesome.
THANK YOU SO MUCH!
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
@neurochen can you format your code according to github markdown?
@neurochen sorry for offtopic. I don’t know how to contact with you by other way. Could you add me in http://github.com/thorlabs , please?