【python】nuitka封裝python

來源:互聯網
上載者:User

標籤:軟體   pytho   stand   提高   官網   targe   class   包含   exe   

官網:http://nuitka.net/doc/user-manual.html

python打包工具對比:http://blog.csdn.net/qwemicheal/article/details/52864656   這篇部落格闡述了nuitka存在的各種問題

elf格式介紹:http://www.cnblogs.com/xmphoenix/archive/2011/10/23/2221879.html  清晰的介紹了elf格式

 

nuitka的作用是將python程式轉換成C語言的可執行elf檔案。這樣在運行時就可以享受到C語言處理過程中的最佳化,提高速度。

 

安裝:
sudo apt-get install nuitka

 

使用:

假設有python檔案 main.py  其中import了  a.py, b.py, c.py

轉換為可執行檔只需運行:

nuitka --recurse-all  main.py

運行後會產生main.exe檔案,注意main.py中import的檔案會被自動包含。

輸入下面代碼即可執行

./main.exe

 

 

問題:

1.跨平台性很差

這點,上面的"python打包工具對比"中也談到了。

具體在我使用時,在ubuntu中打包了一份python檔案,拿到windows下運行,提示

該版本的main.exe 與您啟動並執行 Windows 版本不相容。請查看電腦的系統資訊,瞭解是否需要 x86 (32 位)或 x64 (64 位)版本的程式,然後聯絡軟體發行者。

在centos中運行,提示有python依賴庫找不到。

 

2.使用  --standalone參數後無法產生.exe檔案

官網介紹說使用該參數可以解決代碼對python是否安裝的依賴

The created binaries can be made executable independent of the Python installation, with --standalone option.

可是我用這個參數後就無法產生可執行檔了。

 

【python】nuitka封裝python

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.