I've got an open source python command line program that runs on Python 2.7, Python3+, and is cross platform.
I'm trying to package it up into an executable for my windows users more easily. The source for this package is up on Github here: https://github.com/stormpath/stormpath-cli
I'm trying to package my Python program up using pyinstaller, but am having issues.
I'm running the following commands from a Windows 8 box:
$ pyinstaller --onefile setup.py
This successfully generates an EXE file for me, but when I go to run it, I get the following errors:
Traceback (most recent call last):
File "setup.py", line 4, in <module>
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\setuptools\__init__.py", line 160, in <module>
File "site-packages\setuptools\monkey.py", line 93, in patch_all
File "site-packages\setuptools\monkey.py", line 145, in patch_for_msvc_specialized_compiler
File "importlib\__init__.py", line 37, in import_module
ImportError: No module named msvc
Failed to execute script setup
For testing purposes, to help narrow the issue down, I created a test.py
script that contains the following code:
print('hello, world!')
And then packaged that into an exe as well:
$ pyinstaller --onefile test.py
When I run this resulting exe, everything works great! Hello world is output as expected.
I believe what's happening is that I'm not telling pyinstaller how to properly 'detect' that my project is a python package, and not a single file script.
I've read through the docs a lot, and have googled around, but haven't found a way to specify a package for pyinstaller to analyze.
What am I missing?
While I think it is a perfectly reasonable thing to do, it looks like PyInstaller simply doesn't support building an application from a package (with __main__.py
).
See https://github.com/pyinstaller/pyinstaller/issues/2560.
As a workaround, you can write a small stub (outside of the package) that does the same the same thing as your __main__.py
. Then point PyInstaller at that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With