Running ReadMe in Pythonnet

1

Environment :

  • Pythonnet version: 2.3.0, installed with pip in Amaconda3
  • Python version: 3.6.6 using with Anaconda
  • Visual Studio 2017 Community
  • Operating System: Windows 7, 64 bit

I am running this example from Pythonnet wiki.

using (Py.GIL())
{
                dynamic np = Py.Import("numpy");
                Console.WriteLine(np.cos(np.pi * 2));

                dynamic sin = np.sin;
                Console.WriteLine(sin(5));

                double c = np.cos(5) + sin(5);
                Console.WriteLine(c);

                dynamic a = np.array(new List<float> { 1, 2, 3 });
                Console.WriteLine(a.dtype);

                dynamic b = np.array(new List<float> { 6, 5, 4 }, dtype: np.int32);
                Console.WriteLine(b.dtype);

                Console.WriteLine(a * b);
                Console.ReadKey();
}

result

1.0
-0.9589242746631385
-0.675262089199912
object

error occurs here :

dynamic b = np.array(new List { 6, 5, 4 }, dtype: np.int32);

error message :

Python.Runtime.PythonException: 'TypeError : int() argument must be a string, a bytes-like object or a number, not '0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]''

stack trace :

Python.Runtime.PythonException
  HResult=0x80131500
  Message=TypeError : int() argument must be a string, a bytes-like object or a number, not '0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'
  Source=Python.Runtime
  StackTrace:

Tried Solution but no success :

1) https://github.com/pythonnet/pythonnet/issues/249

2) download zip file from master and run from Amaconda prompt

python setup.py bdist_wheel --xplat
pip install dist\pythonnet-2.4.0.dev0-cp36-cp36m-win64.whl

python setup.py bdist_wheel failed because need import error : mt.exe could not be found I did not restart my pc while installing Visual Studio 2017 Community. So, i think that Visual Studio 2017 Installer did not install mt.exe for me. Restart PC is not an option for me.

===

Would Like to know is there any option to solve this issue, Thank You.

c#
python.net
asked on Stack Overflow Aug 15, 2018 by STREETKILLER007 • edited Jan 1, 2019 by Cœur

1 Answer

1

According to the developer of Pythonnet, i had tried to install the master of pythonnet.

After the installation completed, i run ReadMe successfully.

answered on Stack Overflow Aug 17, 2018 by STREETKILLER007

User contributions licensed under CC BY-SA 3.0