- pyinstaller 4.3
- Navigation
- Project links
- Statistics
- Maintainers
- Classifiers
- Project description
- Main Advantages
- Installation
- Requirements and Tested Platforms
- Usage
- Untested Platforms
- Support
- Funding
- Changes in this Release
- Project details
- Project links
- Statistics
- Can I control the architecture (32bit vs 64bit) when building a pyinstaller executable?
- pyinstaller/PyInstaller/bootloader/Windows-32bit/runw.exe — Virustotal rating 11/60 #2501
- Comments
- AndrewUshakov commented Mar 13, 2017 •
- ghost commented Mar 13, 2017
- ghost commented Mar 13, 2017
- AndrewUshakov commented Mar 13, 2017
- htgoebel commented Mar 13, 2017
- Собираем проект на python3&PyQT5 под Windows, используя PyInstaller
- Немного о Pyinstaller
- Приступаем к сборке
pyinstaller 4.3
pip install pyinstaller Copy PIP instructions
Released: Apr 17, 2021
PyInstaller bundles a Python application and all its dependencies into a single package.
Navigation
Project links
Statistics
View statistics for this project via Libraries.io, or by using our public dataset on Google BigQuery
License: GNU General Public License v2 (GPLv2) (GPLv2-or-later with a special exception which allows to use PyInstaller to build and distribute non-free programs (including commercial ones))
Author: Hartmut Goebel, Giovanni Bajo, David Vierra, David Cortesi, Martin Zibricky
Tags packaging, app, apps, bundle, convert, standalone, executable, pyinstaller, cxfreeze, freeze, py2exe, py2app, bbfreeze
Requires: Python >=3.6
Maintainers
Classifiers
- Development Status
- 6 — Mature
- Environment
- Console
- Intended Audience
- Developers
- Other Audience
- System Administrators
- License
- OSI Approved :: GNU General Public License v2 (GPLv2)
- Natural Language
- English
- Operating System
- MacOS :: MacOS X
- Microsoft :: Windows
- POSIX
- POSIX :: AIX
- POSIX :: BSD
- POSIX :: Linux
- POSIX :: SunOS/Solaris
- Programming Language
- C
- Python
- Python :: 3
- Python :: 3 :: Only
- Python :: 3.6
- Python :: 3.7
- Python :: 3.8
- Python :: 3.9
- Python :: Implementation :: CPython
- Topic
- Software Development
- Software Development :: Build Tools
- Software Development :: Interpreters
- Software Development :: Libraries :: Python Modules
- System :: Installation/Setup
- System :: Software Distribution
- Utilities
Project description
PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules.
Help keeping PyInstaller alive: Maintaining PyInstaller is a huge amount of work. PyInstaller development can only continue if users and companies provide sustainable funding. See http://www.pyinstaller.org/funding.html for how to support PyInstaller.
Documentation: | https://pyinstaller.readthedocs.io/ |
---|---|
Website: | http://www.pyinstaller.org/ |
Code: | https://github.com/pyinstaller/pyinstaller |
Donate, Fund: | http://www.pyinstaller.org/funding.html |
PyInstaller reads a Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files – including the active Python interpreter! – and puts them with your script in a single folder, or optionally in a single executable file.
PyInstaller is tested against Windows, Mac OS X, and GNU/Linux. However, it is not a cross-compiler: to make a Windows app you run PyInstaller in Windows; to make a GNU/Linux app you run it in GNU/Linux, etc. PyInstaller has been used successfully with AIX, Solaris, FreeBSD and OpenBSD, but is not tested against them as part of the continuous integration tests.
Main Advantages
- Works out-of-the-box with any Python version 3.6-3.9.
- Fully multi-platform, and uses the OS support to load the dynamic libraries, thus ensuring full compatibility.
- Correctly bundles the major Python packages such as numpy, PyQt5, PySide2, Django, wxPython, matplotlib and others out-of-the-box.
- Compatible with many 3rd-party packages out-of-the-box. (All the required tricks to make external packages work are already integrated.)
- Libraries like PyQt5, PySide2, wxPython, matplotlib or Django are fully supported, without having to handle plugins or external data files manually.
- Works with code signing on OS X.
- Bundles MS Visual C++ DLLs on Windows.
Installation
PyInstaller is available on PyPI. You can install it through pip :
Requirements and Tested Platforms
- 3.6-3.9
- tinyaes 1.0+ (only if using bytecode encryption). Instead of installing tinyaes, pip install pyinstaller[encryption] instead.
- PyInstaller should work on Windows 7 or newer, but we only officially support Windows 8+.
- We don’t support Python installed from the Windows store when not using virtual environments due to permission errors that can’t easily be fixed.
- ldd: Console application to print the shared libraries required by each program or shared library. This typically can be found in the distribution-package glibc or libc-bin .
- objdump: Console application to display information from object files. This typically can be found in the distribution-package binutils .
- objcopy: Console application to copy and translate object files. This typically can be found in the distribution-package binutils , too.
Usage
Basic usage is very simple, just run it against your main script:
For more details, see the manual.
Untested Platforms
The following platforms have been contributed and any feedback or enhancements on these are welcome.
- AIX 6.1 or newer. PyInstaller will not work with statically linked Python libraries.
- ldd
Before using any contributed platform, you need to build the PyInstaller bootloader, as we do not ship binary packages. Download PyInstaller source, and build the bootloader:
Then install PyInstaller:
or simply use it directly from the source (pyinstaller.py).
Support
See http://www.pyinstaller.org/support.html for how to find help as well as for commercial support.
Funding
Maintaining PyInstaller is a huge amount of work. PyInstaller development can only continue if users and companies provide sustainable funding. See http://www.pyinstaller.org/funding.html for how to support PyInstaller.
Changes in this Release
You can find a detailed list of changes in this release in the change log section of the manual.
Project details
Project links
Statistics
View statistics for this project via Libraries.io, or by using our public dataset on Google BigQuery
License: GNU General Public License v2 (GPLv2) (GPLv2-or-later with a special exception which allows to use PyInstaller to build and distribute non-free programs (including commercial ones))
Author: Hartmut Goebel, Giovanni Bajo, David Vierra, David Cortesi, Martin Zibricky
Tags packaging, app, apps, bundle, convert, standalone, executable, pyinstaller, cxfreeze, freeze, py2exe, py2app, bbfreeze
Can I control the architecture (32bit vs 64bit) when building a pyinstaller executable?
Short Question
Is there any way to control / guarantee the architecture (32bit vs 64bit) when building a pyinstaller executable?
Background
I migrated from py2exe to pyinstaller because of the lack of 64bit support along with a host of small things that I am having a hard time looking past. So on that note, I would prefer not to go back to it. I have developed two applications using Python 2.7 64bit and am having performance issues when running on them 32 bit machines.
The first is a simple wxPython GUI (version 2.9) and connects to a windows DLL file for a USB driver. This one seems pretty «safe» to run as 32 bit because there are no modules which are 64bit only. However this application when running on 32bit Windows XP has horrible performance issues when talking to the USB device.
The second application is much larger and I have not attempted to build and run yet because of the fear of architecture issues. This application has a number 64bit only modules (psycopg2 for one) used in it. I would like to stay away from trying to build this if it impossible to run as a 32bit executable.
Current Thoughts
I feel that this might be possible (if the modules have 32bit support) by running the build.py with Python forced in 32bit mode. Does this make any sense?
Update
I had several breakthroughs on the first program I was building. It turns out the performance issues was solely based on the speed of the two machines. My dev machine had enough power to poll the USB device fast enough and the much slower test platform (Windows XP) did not.
I fixed this issue by modifying the way I polled the USB port. Now that this was fixed, I could run the exe on both systems. A new problem had come up when trying to build the executable as a single file. When running pyinstaller’s Build.py, it pulls in all of the required DLL’s the app needs to run. This seemed to work great at first, but when I tried to run the single exe that I built on Windows 7 64bit, it would not run on Windows XP because the USB dongle’s DLL was not recognized as a valid DLL.
In order to get the single exe to run on both systems, I first tried to remove the DLL from the .spec file (which appears to be a python script). It was convenient because I was able to modify the list of includes prior to the build command with ordinary python list modifiers. My hope was that if the DLL was not found in the exe’s temp directory it would find it on the system PATH. While this approach might work, I could not get it to run without throwing lots of errors.
My second attempt was to build the application on the Windows XP machine (leaving the DLL embedded) in hope that the Win XP DLL would work in Windows 7. Success! This configuration works well; however I do strongly believe that this not the best solution as it depends solely on the older DLL running on a newer OS.
pyinstaller/PyInstaller/bootloader/Windows-32bit/runw.exe — Virustotal rating 11/60 #2501
Comments
AndrewUshakov commented Mar 13, 2017 •
I was informed by our corporate IT, that:
Our bit9 database has detected a file runw.exe as malicious on the server — XXX\XXXXX
File path:: x:\xxxxxxx\xxxxxxxxxxx\my documents\pyinstaller\pyinstaller\bootloader\windows-32bit\
Please delete this file as soon as possible.
I checked this file using virusltotal.com and result is 10/60 which is rather big:
Antivirus | Result | Update |
---|---|---|
AegisLab | Troj.Gen!c | 20170313 |
Antiy-AVL | Trojan[Dropper]/Win32.Sysn | 20170313 |
Jiangmin | Trojan.Agent.asnd | 20170313 |
K7AntiVirus | Trojan ( 00506e781 ) | 20170313 |
K7GW | Trojan ( 00506e781 ) | 20170313 |
NANO-Antivirus | Trojan.Win32.Agent.elyxeb | 20170313 |
Palo Alto Networks (Known Signatures) | Virus/Win32.WGeneric.lldkv | 20170313 |
Rising | Malware.Generic.5!tfe (cloud:4VPvg98eQbI) | 20170313 |
TheHacker | Trojan/Agent.am | 20170311 |
Zillya | Dropper.Sysn.Win32.5954 | 20170310 |
I understand, that this is a ‘false-positive’, but I sure that it is very desirable to have absolutely clean rating 0/70.
Thank you in advance.
The text was updated successfully, but these errors were encountered:
ghost commented Mar 13, 2017
I ran into this problem a while ago but MS appears to have fixed it for windows defender. I don’t know what the answer is; the code is open source for everyone to see. If you have any suggestions, please let us know. Otherwise, nothing is likely to happen.
ghost commented Mar 13, 2017
I looked on carbon’s web site and was unable to find a contact link that I could use. My suggestion is that since you are a paying customer, you can contact them about this false positive.
AndrewUshakov commented Mar 13, 2017
Thank you. I already asked our corporate IT to send this file with information where it is possible to find its source code to «our» anitivirus company,
htgoebel commented Mar 13, 2017
Please contact you anti-virus vendor. There is nothing we can do about this false positive.
If your anti-virus vendor considers one of the files included in the PyInstaller distribution or a file generated by PyInstaller to be malicious, there is nothing we can do about this. Even if we’d change our code, they’d change their pattern and the race starts again.
Собираем проект на python3&PyQT5 под Windows, используя PyInstaller
Причиной написания статьи, явилось огромное количество постоянно возникающих у новичков вопросов такого содержания: «Как собрать проект c pyqt5», «Почему не работает», «Какой инструмент выбрать» и т.д. Сегодня научимся собирать проекты без мучений и танцев с бубном.
Как-то пришлось написать небольшое desktop-приложение. В качестве языка программирования для разработки был выбран python, поскольку для решения моей задачи он подходил идеально. В стандартную библиотеку Python уже входит библиотека tkinter, позволяющая создавать GUI. Но проблема tkinter в том, что данной библиотеке посвящено мало внимания, и найти в интернете курс, книгу или FAQ по ней довольно-таки сложно. Поэтому было решено использовать более мощную, современную и функциональную библиотеку Qt, которая имеет привязки к языку программирования python в виде библиотеки PyQT5. Более подробно про PyQT можете почитать здесь. В качестве примера я буду использовать код:
Если вы более-менее опытный разработчик, то понимаете, что без интерпретатора код на python не запустить. А хотелось бы дать возможность каждому пользователю использовать программу. Вот здесь к нам на помощь и приходят специальные библиотеки позволяющие собирать проекты в .exe, которые можно потом без проблем запустить, как обычное приложение.
Существует большое количество библиотек, позволяющих это сделать, среди которых самые популярные: cx_Freeze, py2exe, nuitka, PyInstaller и др. Про каждую написано довольно много. Но надо сказать, что многие из этих решений позволяют запускать код только на компьютере, с предустановленным интерпретатором и pyqt5. Не думаю, что пользователь будет заморачиваться и ставить себе дополнительные пакеты и программы. Надеюсь, вы понимаете, что запуск программы на dev-среде и у пользователя это не одно и тоже. Также нужно отметить, что у каждого решения были свои проблемы: один не запускался, другой собирал то, что не смог потом запустить, третий вообще отказывался что-либо делать.
После долгих танцев с бубном и активным гуглением, мне все же удалось собрать проект с помощью pyinstaller, в полностью работоспособное приложение.
Немного о Pyinstaller
Pyinstaller собирает python-приложение и все зависимости в один пакет. Пользователь может запускать приложение без установки интерпретатора python или каких-либо модулей. Pyinstaller поддерживает python 2.7 и python 3.3+ и такие библиотеки как: numpy, PyQt, Django, wxPython и другие.
Pyinstaller тестировался на Windows, Mac OS X и Linux. Как бы там ни было, это не кросс-платформенный компилятор: чтобы сделать приложение под Windows, делай это на Windows; Чтобы сделать приложение под Linux, делай это на Linux и т.д.
PyInstaller успешно используется с AIX, Solaris и FreeBSD, но тестирование не проводилось.
Подробнее о PyInstaller можно почитать здесь: документация.
К тому же после сборки приложение весило всего около 15 мб. Это к слову и является преимуществом pyinstaller, поскольку он не собирает все подряд, а только необходимое. Аналогичные же библиотеки выдавали результат за 200-300 мб.
Приступаем к сборке
Прежде чем приступить к сборке мы должны установить необходимые библиотеки, а именно pywin32 и собственно pyinstaller:
Чтобы убедится, что все нормально установилось, вводим команду:
должна высветиться версия pyinstaller. Если все правильно установилось, идем дальше.
В папке с проектом запускаем cmd и набираем:
Собственно это и есть простейшая команда, которая соберет наш проект.
Синтаксис команды pyinstaller таков:
pyinstaller [options] script [script . ] | specfile
Наиболее часто используемые опции:
—onefile — сборка в один файл, т.е. файлы .dll не пишутся.
—windowed -при запуске приложения, будет появляться консоль.
—noconsole — при запуске приложения, консоль появляться не будет.
—icon=app.ico — добавляем иконку в окно.
—paths — возможность вручную прописать путь к необходимым файлам, если pyinstaller
не может их найти(например: —paths D:\python35\Lib\site-packages\PyQt5\Qt\bin)
PyInstaller анализирует файл myscript.py и делает следующее:
- Пишет файл myscript.spec в той же папке, где находится скрипт.
- Создает папку build в той же папке, где находится скрипт.
- Записывает некоторые логи и рабочие файлы в папку build.
- Создает папку dist в той же папке, где находится скрипт.
- Пишет исполняемый файл в папку dist.
В итоге наша команда будет выглядеть так:
После работы программы вы найдете две папки: dist и build. Собственно в папке dist и находится наше приложение. Впоследствии папку build можно спокойно удалить, она не влияет на работоспособность приложения.
Спасибо за внимание. Надеюсь статья была вам полезна.