Windows上的Nuitka [英] Nuitka on Windows

查看:969
本文介绍了Windows上的Nuitka的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows上使用Nuitka编译hello-world.py时遇到问题.

Having problems to compile hello-world.py using Nuitka on windows.

我正在使用的命令是:

nuitka --standalone --portable --remove-output --recurse-all --python-version=3.4 hello_world.py

错误是:

WindowsError: [Error 2] The system cannot find the file specified:
File "C:\Users\win_user\Anaconda3\Lib\site-packages\nuitka\build\SingleExe.scons", line 866:
shell       = False
File "c:\Python27\lib\subprocess.py", line 709:
errread, errwrite)
File "c:\Python27\lib\subprocess.py", line 957:
startupinfo)

相同的代码会编译并生成在Linux上运行良好.在Windows的解释器中,相同的代码运行良好.

Same code compiles & runs fine on Linux. Same code runs fine in interpreter on windows.

错误消息中提到的文件确实存在.有什么建议吗?

The files mentioned in the error message do actually exist. Any suggestions?

使用Win7. Python 3.4(Anaconda x64).使用MinGW.

Using Win7. Python 3.4 (Anaconda x64). Using MinGW.

推荐答案

好,对于有相同错误的任何人,这里都是我自己的问题的答案:

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

我无法让MinGW工作.我最终安装了MSVC2010.这可能会更好,因为无论如何建议在Windows上使用Python 3.4(请参阅: https ://docs.python.org/3.4/using/windows.html#compiling-python-on-windows ).

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).

以下是在带有MSVC ++ 2010和Win7 64位的python 3.4上安装Nuitka的说明:

其他有关MSVC2010的有用说明,在这里:
1. https://wiki.qt.io/How_to_setup_MSVC2010
2.

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

步骤是:

  1. 安装.net 4.x:
    运行 dotNetFx40_Full_setup.exe (来自
    http://www.microsoft .com/en-gb/download/confirmation.aspx?id = 17851 )

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

安装Visual C ++ 2010 Express:
运行 vc_web.exe (从 http: //microsoft-visual-cpp-express.soft32.com/download/file/id/795918/?no_download_manager=true )

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)

UN -安装任何更新的或等于10.0.30319的Visual C ++ 2010运行时/可再发行版本.没有要删除的内容)

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)

安装Windows SDK 7.1 :(选择所有安装选项)
运行 winsdk_web.exe (来自 https://www.microsoft .com/en-us/download/details.aspx?id = 8279 )

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)

安装VS 2010 SP1:
运行 VS10sp1-KB983509.exe (来自 http://www .microsoft.com/en-au/download/details.aspx?id = 23691 )

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

安装MSVC 2010 SP1编译器更新:
运行 VC-Compiler-KB2519277.exe (来自 http://www.microsoft.com/en-au/download/details.aspx?id=4422 )

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

现在已安装C编译器.

C compiler now installed.

  1. 要在64位计算机上进行测试,我发现缺少文件,必须手动创建. (请参见此处: http://www.w7forums.com /threads/vcvarsall-bat-no-64bit-support-vcvars64-bat-missing.6606/)
    要修复,请创建一个名为: C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ vc \ bin \ amd64 \ vcvars64.bat 的文件. 在文件中,输入文本 CALL"C:\ Program Files \ Microsoft SDKs \ Windows \ v7.1 \ Bin \ SetEnv.cmd"/x64

  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

设置环境:
运行"C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ vcvarsall" amd64
上面的命令后,控制台文本应变为黄色.
(有关amd64以外的其他选项,请参见此处: https://msdn.microsoft.com/en-us/library /f2ccy3wt.aspx )

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)

编译测试程序:(在cmd文本仍为黄色时执行此操作)
cl hello.c
(假设您的测试程序称为 hello.c )

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

运行测试程序:
hello.exe

Run test program:
hello.exe

C编译器现已测试.

  1. 安装python 2.7 :(即使python代码为3.x,Nuitka也需要此)
    运行 python-2.7.6.amd64.msi (来自

  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)

安装python 3.4:(Anaconda堆栈似乎是在Windows上获取此代码的最明智的方法)
运行 Anaconda3-2.3.0-Windows-x86_64.exe (来自

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)

安装Nuitka :(一直都是较新的版本,因此最好检查 http://nuitka.net/pages/download. html )
运行 Nuitka-5.1.143.win-amd64.py34.msi (来自

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)

所有安装现已完成!

  1. 测试Nuitka :(假设您的测试程序为 hello.py )
    "C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ vcvarsall" amd64
    nuitka --standalone --portable hello.py
    cd hello.dist
    hello.exe
  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

在首次使用nuitka时,它发出了以下通知:"Nuitka将使用Dependency Walker( http://dependencywalker.com )工具来分析Python扩展模块的依赖性.是否可以下载并将其放入APPDATA中(无需安装程序,无需缓存,只需一次提问).继续并下载?[是]/否".我说是,然后您好,世界程序开始工作了.

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在执行此过程后仍然有效,但是某些更复杂的程序上的某些导入会引起警告.当我找出答案时,将编辑我的答案.还是会问另一个问题,如果我不知道.

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.

这篇关于Windows上的Nuitka的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆