Skip to content

TypeError when running ReadMe example Year 2018 #719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
STREETKILLER007 opened this issue Aug 15, 2018 · 8 comments
Closed

TypeError when running ReadMe example Year 2018 #719

STREETKILLER007 opened this issue Aug 15, 2018 · 8 comments

Comments

@STREETKILLER007
Copy link

STREETKILLER007 commented Aug 15, 2018

I have the following settings:

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

I run this code, and it pops out this error.

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);"

I get the following error:
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 still have not solve :

  1. referred Errors with example calling Python from .NET #249

  2. referred TypeError when running ReadMe example  #554
    download zip file 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.

while running on Visual Studio 2017 that fully installed, i found this issue in python setup.py bdist_wheel --xplat

delegatemanager.cs(204,13): warning CS0162: Unreachable code detected [C:\Users
\JamesTan\Desktop\pythonnetmaster\pythonnet-master\src\runtime\Python.Runtime.1
5.csproj]

pythonexception.cs(67,13): warning CS0162: Unreachable code detected [C:\Users\
JamesTan\Desktop\pythonnetmaster\pythonnet-master\src\runtime\Python.Runtime.15
.csproj]

pyobject.cs(51,13): warning CS0162: Unreachable code detected [C:\Users\JamesTa
n\Desktop\pythonnetmaster\pythonnet-master\src\runtime\Python.Runtime.15.csproj]

pyscope.cs(534,13): warning CS0162: Unreachable code detected [C:\Users\JamesTa
n\Desktop\pythonnetmaster\pythonnet-master\src\runtime\Python.Runtime.15.csproj]

delegatemanager.cs(204,13): warning CS0162: Unreachable code detected [C:\Users
\JamesTan\Desktop\pythonnetmaster\pythonnet-master\src\runtime\Python.Runtime.1
5.csproj]

pyobject.cs(51,13): warning CS0162: Unreachable code detected [C:\Users\JamesTa
n\Desktop\pythonnetmaster\pythonnet-master\src\runtime\Python.Runtime.15.csproj]

pyscope.cs(534,13): warning CS0162: Unreachable code detected [C:\Users\JamesTa
n\Desktop\pythonnetmaster\pythonnet-master\src\runtime\Python.Runtime.15.csproj]

pythonexception.cs(67,13): warning CS0162: Unreachable code detected [C:\Users\
JamesTan\Desktop\pythonnetmaster\pythonnet-master\src\runtime\Python.Runtime.15
.csproj]

dynamic.cs(121,28): warning CS0618: 'PythonEngine.RunString(string, IntPtr?, In
tPtr?)' is obsolete: 'RunString is deprecated and will be removed. Use Exec/Eva
l/RunSimpleString instead.' [C:\Users\JamesTan\Desktop\pythonnetmaster\pythonne
t-master\src\embed_tests\Python.EmbeddingTest.15.csproj]

dynamic.cs(121,28): warning CS0618: 'PythonEngine.RunString(string, IntPtr?, In
tPtr?)' is obsolete: 'RunString is deprecated and will be removed. Use Exec/Eva
l/RunSimpleString instead.' [C:\Users\JamesTan\Desktop\pythonnetmaster\pythonne
t-master\src\embed_tests\Python.EmbeddingTest.15.csproj]

C:\Users\JamesTan\.nuget\packages\unmanagedexports\1.2.7\tools\RGiesecke.DllExp
ort.targets(58,3): error : Microsoft.Build.Utilities.ToolLocationHelper could n
ot find ildasm.exe. [C:\Users\JamesTan\Desktop\pythonnetmaster\pythonnet-master
\src\clrmodule\clrmodule.15.csproj]

Run pip install dist\pythonnet-2.4.0.dev0-cp36-cp36m-win64.whl
this error occurs

Requirement 'dist\\pythonnet-2.4.0.dev0-cp36-cp36m-win64.whl' looks like a filen
ame, but the file does not exist
pythonnet-2.4.0.dev0-cp36-cp36m-win64.whl is not a supported wheel on this platf
orm.

===

Would like to ask that, is there any option to solve this ? Thank you,

@den-run-ai
Copy link
Contributor

@STREETKILLER007 just grab the wheels from appveyor ci artifacts, in VS 2017 you probably do not have the C/C++ compilers installed. You can search for mt.exe in Windows Explorer and report back the path if you have it.

@STREETKILLER007
Copy link
Author

but i had installed these in my visual studio.

capture

@den-run-ai den-run-ai reopened this Aug 15, 2018
@den-run-ai
Copy link
Contributor

Then what is the path for mt.exe on your machine?

@STREETKILLER007
Copy link
Author

@denfromufa

The location of mt.exe is as below

C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\arm64
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86
C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\arm64
C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64
C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86

@den-run-ai
Copy link
Contributor

@STREETKILLER007 try updating vswhere.exe in pythonnet\tools. It is possible that some new VS 2017 paths were added recently:

https://github.com/Microsoft/vswhere/releases

But it should be easier to grab binaries from appveyor.

@STREETKILLER007
Copy link
Author

Hmm, i read the github page.

But i did not see any installation steps.

Would like to ask some help here...

@STREETKILLER007
Copy link
Author

STREETKILLER007 commented Aug 15, 2018

I choose Environment: PYTHON_VERSION=3.6, BUILD_OPTS=--xplat; Platform: x64 and press archieve.
After that, i run pip install pythonnet-2.4.0.dev0-cp36-cp36m-win64.whl

than i run back the example, it works nice.

pythonnet is version 2.4.0.de

Thank for the help.

===

I am trying to do this example another machine in cyber cafe.
When install Visual Studio in that machine, i will choose the same things to install.
i will not restart it since if i restart, the machine will reset to its default state.

in that machine, i can't find mt.exe.

When pip install pythonnet-2.4.0.dev0-cp36-cp36m-win64.whl, it still works fine.

run example in that machine.

It showed same result, works nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants