From denis.akhiyarov at gmail.com Fri Nov 30 09:41:21 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Fri, 30 Nov 2018 08:41:21 -0600 Subject: [Python.NET] PythonNet support for Python 3.7 In-Reply-To: References: Message-ID: pythonnet support for Python 3.7 is in the master branch. On Fri, Oct 12, 2018 at 12:22 AM Denis Akhiyarov wrote: > Would you like to contribute Python 3.7 support? > > On Fri, Oct 12, 2018, 12:17 AM Surya Kant Pradhan < > surya.pradhan123 at gmail.com> wrote: > >> Hi Dev Community, >> >> I was following the list of issues under: >> https://github.com/pythonnet/pythonnet/issues/609, but not getting an >> idea on when possibly is the release timeline for officially supporting >> Python 3.7. >> >> If you can share some rough estimates on a possible release date, it >> would really help us decide our own migration plans. >> >> Thanks, >> Surya. >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Fri Nov 30 09:42:41 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Fri, 30 Nov 2018 08:42:41 -0600 Subject: [Python.NET] Pip Install Pythonnet error In-Reply-To: References: Message-ID: The error you got was due to python 3.7 for which support is in the master branch now. On Fri, Oct 12, 2018 at 12:17 AM Phat Loc wrote: > Forget the last previous error. I running anaconda and there is a > different setup process. Thanks! > > > > *From:* Phat Loc > *Sent:* Wednesday, October 10, 2018 9:29 AM > *To:* 'pythondotnet at python.org' > *Subject:* Pip Install Pythonnet error > > > > Hi All, > > > > I am trying do a pip install of pythonnet. I get the following build > errors. Any suggestions on how to fix it? > > > > > > (base) C:\Users\ploc>pip install pythonnet > > Collecting pythonnet > > Using cached > https://files.pythonhosted.org/packages/89/3b/a22cd45b591d6cf490e > > e8b24d52b9db1f30b4b478b64a9b231c53474731e/pythonnet-2.3.0.tar.gz > > Building wheels for collected packages: pythonnet > > Running setup.py bdist_wheel for pythonnet ... error > > Complete output from command > c:\users\ploc\appdata\local\continuum\anaconda3\p > > ython.exe -u -c "import setuptools, > tokenize;__file__='C:\\Users\\ploc\\AppData\ > > \Local\\Temp\\pip-install-r86ym617\\pythonnet\\setup.py';f=getattr(tokenize, > 'op > > en', open)(__file__);code=f.read().replace('\r\n', > '\n');f.close();exec(compile( > > code, __file__, 'exec'))" bdist_wheel -d > C:\Users\ploc\AppData\Local\Temp\pip-wh > > eel-9cgf0yo2 --python-tag cp37: > > running bdist_wheel > > running build > > running build_ext > > Checking for updates from https://www.nuget.org/api/v2/. > > Currently running NuGet.exe 3.5.0. > > Updating NuGet.exe to 4.7.1. > > Update successful. > > MSBuild auto-detection: using msbuild version '15.6.82.30579' from > 'C:\Program > > Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin'. > > Restoring NuGet package NUnit.3.6.0. > > Restoring NuGet package UnmanagedExports.1.2.7. > > Restoring NuGet package NUnit.ConsoleRunner.3.6.0. > > Adding package 'NUnit.ConsoleRunner.3.6.0' to folder > 'C:\Users\ploc\AppData\Lo > > cal\Temp\pip-install-r86ym617\pythonnet\packages' > > Adding package 'NUnit.3.6.0' to folder > 'C:\Users\ploc\AppData\Local\Temp\pip-i > > nstall-r86ym617\pythonnet\packages' > > Adding package 'UnmanagedExports.1.2.7' to folder > 'C:\Users\ploc\AppData\Local > > \Temp\pip-install-r86ym617\pythonnet\packages' > > Added package 'UnmanagedExports.1.2.7' to folder > 'C:\Users\ploc\AppData\Local\ > > Temp\pip-install-r86ym617\pythonnet\packages' > > Added package 'NUnit.ConsoleRunner.3.6.0' to folder > 'C:\Users\ploc\AppData\Loc > > al\Temp\pip-install-r86ym617\pythonnet\packages' > > Added package 'NUnit.3.6.0' to folder > 'C:\Users\ploc\AppData\Local\Temp\pip-in > > stall-r86ym617\pythonnet\packages' > > > > NuGet Config files used: > > C:\Users\ploc\AppData\Roaming\NuGet\NuGet.Config > > C:\Program Files > (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config > > > > Feeds used: > > C:\Users\ploc\.nuget\packages\ > > https://www.nuget.org/api/v2/ > > http://nuget.grapecity.com/nuget > > C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\ > > > > Installed: > > 3 package(s) to packages.config projects > > Traceback (most recent call last): > > File "tools\geninterop\geninterop.py", line 292, in > > sys.exit(main()) > > File "tools\geninterop\geninterop.py", line 272, in main > > python_h = preprocess_python_headers() > > File "tools\geninterop\geninterop.py", line 192, in > preprocess_python_header > > s > > for line in _check_output(cmd).splitlines(): > > File "tools\geninterop\geninterop.py", line 41, in _check_output > > output = subprocess.check_output(*args, **kwargs) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", li > > ne 376, in check_output > > **kwargs).stdout > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", li > > ne 453, in run > > with Popen(*popenargs, **kwargs) as process: > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", li > > ne 756, in __init__ > > restore_signals, start_new_session) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", li > > ne 1155, in _execute_child > > startupinfo) > > FileNotFoundError: [WinError 2] The system cannot find the file specified > > Traceback (most recent call last): > > File "", line 1, in > > File > "C:\Users\ploc\AppData\Local\Temp\pip-install-r86ym617\pythonnet\setup. > > py", line 405, in > > zip_safe=False, > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\site-packages\setu > > ptools\__init__.py", line 140, in setup > > return distutils.core.setup(**attrs) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\core.py" > > , line 148, in setup > > dist.run_commands() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\dist.py" > > , line 966, in run_commands > > self.run_command(cmd) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\dist.py" > > , line 985, in run_command > > cmd_obj.run() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\site-packages\whee > > l\bdist_wheel.py", line 188, in run > > self.run_command('build') > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\cmd.py", > > line 313, in run_command > > self.distribution.run_command(command) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\dist.py" > > , line 985, in run_command > > cmd_obj.run() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\command\ > > build.py", line 135, in run > > self.run_command(cmd_name) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\cmd.py", > > line 313, in run_command > > self.distribution.run_command(command) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\dist.py" > > , line 985, in run_command > > cmd_obj.run() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\command\ > > build_ext.py", line 339, in run > > self.build_extensions() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\command\ > > build_ext.py", line 448, in build_extensions > > self._build_extensions_serial() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\command\ > > build_ext.py", line 473, in _build_extensions_serial > > self.build_extension(ext) > > File > "C:\Users\ploc\AppData\Local\Temp\pip-install-r86ym617\pythonnet\setup. > > py", line 191, in build_extension > > subprocess.check_call([sys.executable, geninterop, interop_file]) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", li > > ne 328, in check_call > > raise CalledProcessError(retcode, cmd) > > subprocess.CalledProcessError: Command > '['c:\\users\\ploc\\appdata\\local\\con > > tinuum\\anaconda3\\python.exe', 'tools\\geninterop\\geninterop.py', > 'src\\runtim > > e\\interop37.cs']' returned non-zero exit status 1. > > > > ---------------------------------------- > > Failed building wheel for pythonnet > > Running setup.py clean for pythonnet > > Failed to build pythonnet > > Installing collected packages: pythonnet > > Running setup.py install for pythonnet ... error > > Complete output from command > c:\users\ploc\appdata\local\continuum\anaconda3 > > \python.exe -u -c "import setuptools, > tokenize;__file__='C:\\Users\\ploc\\AppDat > > a\\Local\\Temp\\pip-install-r86ym617\\pythonnet\\setup.py';f=getattr(tokenize, > ' > > open', open)(__file__);code=f.read().replace('\r\n', > '\n');f.close();exec(compil > > e(code, __file__, 'exec'))" install --record > C:\Users\ploc\AppData\Local\Temp\pi > > p-record-qmhk9uw7\install-record.txt --single-version-externally-managed > --compi > > le: > > running install > > running build > > running build_ext > > Checking for updates from https://www.nuget.org/api/v2/. > > Currently running NuGet.exe 4.7.1. > > NuGet.exe is up to date. > > MSBuild auto-detection: using msbuild version '15.6.82.30579' from > 'C:\Progr > > am Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin'. > > All packages listed in packages.config are already installed. > > Traceback (most recent call last): > > File "tools\geninterop\geninterop.py", line 292, in > > sys.exit(main()) > > File "tools\geninterop\geninterop.py", line 272, in main > > python_h = preprocess_python_headers() > > File "tools\geninterop\geninterop.py", line 192, in > preprocess_python_head > > ers > > for line in _check_output(cmd).splitlines(): > > File "tools\geninterop\geninterop.py", line 41, in _check_output > > output = subprocess.check_output(*args, **kwargs) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", > > line 376, in check_output > > **kwargs).stdout > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", > > line 453, in run > > with Popen(*popenargs, **kwargs) as process: > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", > > line 756, in __init__ > > restore_signals, start_new_session) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", > > line 1155, in _execute_child > > startupinfo) > > FileNotFoundError: [WinError 2] The system cannot find the file > specified > > Traceback (most recent call last): > > File "", line 1, in > > File > "C:\Users\ploc\AppData\Local\Temp\pip-install-r86ym617\pythonnet\setu > > p.py", line 405, in > > zip_safe=False, > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\site-packages\se > > tuptools\__init__.py", line 140, in setup > > return distutils.core.setup(**attrs) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\core.p > > y", line 148, in setup > > dist.run_commands() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\dist.p > > y", line 966, in run_commands > > self.run_command(cmd) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\dist.p > > y", line 985, in run_command > > cmd_obj.run() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\site-packages\se > > tuptools\command\install.py", line 61, in run > > return orig.install.run(self) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\comman > > d\install.py", line 545, in run > > self.run_command('build') > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\cmd.py > > ", line 313, in run_command > > self.distribution.run_command(command) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\dist.p > > y", line 985, in run_command > > cmd_obj.run() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\comman > > d\build.py", line 135, in run > > self.run_command(cmd_name) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\cmd.py > > ", line 313, in run_command > > self.distribution.run_command(command) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\dist.p > > y", line 985, in run_command > > cmd_obj.run() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\comman > > d\build_ext.py", line 339, in run > > self.build_extensions() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\comman > > d\build_ext.py", line 448, in build_extensions > > self._build_extensions_serial() > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\distutils\comman > > d\build_ext.py", line 473, in _build_extensions_serial > > self.build_extension(ext) > > File > "C:\Users\ploc\AppData\Local\Temp\pip-install-r86ym617\pythonnet\setu > > p.py", line 191, in build_extension > > subprocess.check_call([sys.executable, geninterop, interop_file]) > > File > "c:\users\ploc\appdata\local\continuum\anaconda3\lib\subprocess.py", > > line 328, in check_call > > raise CalledProcessError(retcode, cmd) > > subprocess.CalledProcessError: Command > '['c:\\users\\ploc\\appdata\\local\\c > > ontinuum\\anaconda3\\python.exe', 'tools\\geninterop\\geninterop.py', > 'src\\runt > > ime\\interop37.cs']' returned non-zero exit status 1. > > > > ---------------------------------------- > > Command "c:\users\ploc\appdata\local\continuum\anaconda3\python.exe -u -c > "impor > > t setuptools, > tokenize;__file__='C:\\Users\\ploc\\AppData\\Local\\Temp\\pip-inst > > all-r86ym617\\pythonnet\\setup.py';f=getattr(tokenize, 'open', > open)(__file__);c > > ode=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, > 'exec' > > ))" install --record > C:\Users\ploc\AppData\Local\Temp\pip-record-qmhk9uw7\instal > > l-record.txt --single-version-externally-managed --compile" failed with > error co > > de 1 in C:\Users\ploc\AppData\Local\Temp\pip-install-r86ym617\pythonnet\ > > > > Thanks, > > > > Phat > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > https://mail.python.org/mailman/listinfo/pythondotnet > -------------- next part -------------- An HTML attachment was scrubbed... URL: From denis.akhiyarov at gmail.com Fri Nov 30 09:49:27 2018 From: denis.akhiyarov at gmail.com (Denis Akhiyarov) Date: Fri, 30 Nov 2018 08:49:27 -0600 Subject: [Python.NET] Embedded Python .Net example - running scripts In-Reply-To: References: <1651768403.3910584.1538619134927@mail.yahoo.com> Message-ID: Reloading/shutdown support of embedding CPython with pythonnet was added in the master branch. See this pull request: https://github.com/pythonnet/pythonnet/pull/752 On Thu, Oct 4, 2018 at 9:50 PM Denis Akhiyarov wrote: > Please search the issue tracker on github for shutdown related issues. > This was discussed extensively. > > There is WIP pull request worked on by 3 people to support this reloading > scenario in Unity. > > > On Wed, Oct 3, 2018, 9:50 PM Ron Harding via PythonDotNet < > pythondotnet at python.org> wrote: > >> Did you try background or threadpool threads? Redirected process calls >> and looking for stdin stdout stderr streams allows more control. >> >> Sent from Yahoo Mail on Android >> >> >> On Wed, Oct 3, 2018 at 15:47, Luke, Steve >> wrote: >> >> I am getting a crash trying to embed Python into my VB program using >> Python for .NET. The goal of my application is to allow users to run >> their own python scripts inside a larger application. The crash I am >> getting happens the second time I run a script that imports certain large >> libraries (like numpy or scikit-image) but does not affect all libraries >> (for example PIL). >> >> >> >> My environment: >> >> Windows 10 Pro x64, Python 3.6.5 (in Anaconda), Python for .Net 2.4.0 >> (installed from git?s master branch). >> >> >> >> Here is the VB code: >> >> Public Function Startup(ByRef param As String) As Integer >> >> PythonEngine.Initialize() >> >> 'mm.PrintMsg(PythonEngine.BuildInfo) >> >> 'mm.PrintMsg(PythonEngine.Compiler) >> >> 'mm.PrintMsg(PythonEngine.Platform) >> >> 'mm.PrintMsg(PythonEngine.ProgramName) >> >> 'mm.PrintMsg(PythonEngine.PythonHome) >> >> 'mm.PrintMsg(PythonEngine.PythonPath) >> >> Using (Py.GIL()) >> >> >> >> Dim scriptPath As String = param >> >> >> >> Dim scriptDir As String = Path.GetDirectoryName(scriptPath) >> >> Dim scriptName As String = GetPythonModuleName(scriptPath) >> >> Dim scriptParam As String = "" >> >> >> >> Dim scriptScope As PyScope = Py.CreateScope() >> >> >> >> Dim scriptText As String = >> My.Computer.FileSystem.ReadAllText(scriptPath) >> >> scriptScope.Exec(scriptText) >> >> >> >> If scriptScope.Contains(STARTUP_METHOD_NAME) Then >> >> scriptScope.Exec(String.Format("{0}(r'{1}')", >> STARTUP_METHOD_NAME, scriptParam)) >> >> End If >> >> >> >> scriptScope.Dispose() >> >> End Using >> >> PythonEngine.Shutdown() >> >> >> >> Return 0 >> >> End Function >> >> >> >> And this is the Python script I am running: >> >> import skimage.io >> >> >> >> def Startup(param): >> >> pass >> >> >> >> def Docommand(param): >> >> pass >> >> >> >> def Shutdown(): >> >> pass >> >> >> >> When I run it the VB code the first time, things work great. When I run >> the VB code a second time (without first restarting the entire application) >> I get an access violation exception on the scriptScope.Exec() call: >> >> *Exception:* System.AccessViolationException : >> >> *Message:* Attempted to read or write protected memory. This is often an >> indication that other memory is corrupt. >> >> *Source:* Python.Runtime >> >> *StackTrace:* >> >> at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, >> IntPtr kw) >> >> at Python.Runtime.Runtime.PyRun_String(String code, IntPtr st, IntPtr >> globals, IntPtr locals) >> >> at Python.Runtime.PyScope.Exec(String code, IntPtr _globals, IntPtr >> _locals) >> >> at MyApp.MyClass.Startup(String& param) in >> C:\Git\MyPath\MyApp.vb:line 132 >> >> Unfortunately the stack trace doesn't show line numbers for anything in >> the Python.Runtime. >> >> >> >> Interestingly, if you look at the VB code, I have some lines of commented >> out code: >> >> 'mm.PrintMsg(PythonEngine.BuildInfo) >> >> 'mm.PrintMsg(PythonEngine.Compiler) >> >> 'mm.PrintMsg(PythonEngine.Platform) >> >> 'mm.PrintMsg(PythonEngine.ProgramName) >> >> 'mm.PrintMsg(PythonEngine.PythonHome) >> >> 'mm.PrintMsg(PythonEngine.PythonPath) >> >> >> Since the app doesn?t have a console, this sends the text to the >> enclosing app for display. If I uncommon that code, then the first time >> I run it I get: >> >> default, Mar 29 2018, 13:32:41 >> >> [MSC v.1900 64 bit (AMD64)] >> >> win32 >> >> python >> >> >> >> F:\Anaconda3\python36.zip;F:\Anaconda3\Lib;F:\Anaconda3\DLLs;C:\MX6 >> >> >> >> And the second time I run it I get: >> >> default, Mar 29 2018, 13:32:41 >> >> [MSC v.1900 64 bit (AMD64)] >> >> win32 >> >> *pyth???* >> >> *???* >> >> F:\Anaconda3\python36.zip;F:\Anaconda3\Lib;F:\Anaconda3\DLLs;C:\MX6 >> >> >> >> And the application doesn?t crash! Instead it just says the skimage >> module can?t be found. Notice the bolded lines (bold added after the >> fact). The program name and python home values are being corrupted. >> >> Is there something I am doing wrong as far as taking down the >> PythonEngine such that it could be put back up in an as-new state later on? >> >> >> Steve >> >> >> Please be advised that this email may contain confidential information. >> If you are not the intended recipient, please notify us by email by >> replying to the sender and delete this message. The sender disclaims that >> the content of this email constitutes an offer to enter into, or the >> acceptance of, any agreement; provided that the foregoing does not >> invalidate the binding effect of any digital or other electronic >> reproduction of a manual signature that is included in any attachment. >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> https://mail.python.org/mailman/listinfo/pythondotnet >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: