Nuitka on Windows

旧城冷巷雨未停 提交于 2019-12-04 07:54:28

OK, for the benefit of anyone who has the same error, here is the answer to my own question:

I failed to get MinGW working. I eventually got MSVC2010 installed instead. This is maybe better since it is recommended for Python 3.4 on Windows anyway (see: https://docs.python.org/3.4/using/windows.html#compiling-python-on-windows).

Below are instructions for installing Nuitka using python 3.4 with MSVC++2010 and Win7 64bit:

Other helpful instructions for MSVC2010 are here:
1. https://wiki.qt.io/How_to_setup_MSVC2010
2. http://uk.mathworks.com/matlabcentral/answers/95039-why-does-the-sdk-7-1-installation-fail-with-an-installation-failed-message-on-my-windows-system

Steps are:

  1. Install .net 4.x:
    run dotNetFx40_Full_setup.exe (from http://www.microsoft.com/en-gb/download/confirmation.aspx?id=17851)

  2. Install Visual C++ 2010 Express:
    run vc_web.exe (from http://microsoft-visual-cpp-express.soft32.com/download/file/id/795918/?no_download_manager=true)

  3. UN-install any Visual C++ 2010 runtime/redistributable newer or equal to 10.0.30319.
    (In my case I had a clean windows install for this setup so there was nothing to remove)

  4. Install Windows SDK 7.1: (select all install options)
    run winsdk_web.exe (from https://www.microsoft.com/en-us/download/details.aspx?id=8279)

  5. Install VS 2010 SP1:
    run VS10sp1-KB983509.exe (from http://www.microsoft.com/en-au/download/details.aspx?id=23691)

  6. Install MSVC 2010 SP1 Compiler Update:
    run VC-Compiler-KB2519277.exe (from http://www.microsoft.com/en-au/download/details.aspx?id=4422)

C compiler now installed.

  1. To test on 64 bit machines I found that there is a file missing, which has to be manually created. (See here: http://www.w7forums.com/threads/vcvarsall-bat-no-64bit-support-vcvars64-bat-missing.6606/)
    To fix create a file called: C:\Program Files (x86)\Microsoft Visual Studio 10.0\vc\bin\amd64\vcvars64.bat In the file put the text CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64

  2. Set-up environment:
    run "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall" amd64
    Console text should go yellow after above command.
    (See here for options other than amd64: https://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx)

  3. Compile test program: (do this while cmd text is still yellow)
    cl hello.c
    (assuming your test program is called hello.c)

  4. Run test program:
    hello.exe

C compiler now tested.

  1. Install python 2.7: (Nuitka needs this even if the python code is 3.x)
    run python-2.7.6.amd64.msi (from https://www.python.org/ftp/python/2.7.6/python-2.7.6.amd64.msi)

  2. Install python 3.4: (Anaconda stack seems to be the sanest way to get this on Windows)
    run Anaconda3-2.3.0-Windows-x86_64.exe (from https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda3-2.3.0-Windows-x86_64.exe)

  3. Install Nuitka: (newer versions all the time so better check http://nuitka.net/pages/download.html)
    run Nuitka-5.1.143.win-amd64.py34.msi (from http://nuitka.net/releases/Nuitka-5.1.143.win-amd64.py34.msi)

All install now done!

  1. Test Nuitka: (assuming your test program is hello.py)
    "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall" amd64
    nuitka --standalone --portable hello.py
    cd hello.dist
    hello.exe

On the first usage of nuitka it gave this notice: "Nuitka will make use of Dependency Walker (http://dependencywalker.com) tool to analyze the dependencies of Python extension modules. Is it OK to download and put it in APPDATA (no installer needed, cached, one time question). Proceed and download? [Yes]/No". I said yes and then the hello world program worked.

Hello world worked after this procedure but some imports on more complicated programs cause warnings. Will edit my answer when I figure that one out. Or will ask another question if I can't figure it out.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!