Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using py2exe in a virtualenv

Tags:

python

py2exe

I have a Python script I developed within a virtualenv on Windows (Python 2.7).

I would now like to compile it into a single EXE using Py2exe.

I've read and read the docs and stackoverflow, and yet I can't find a simple answer: How do I do this? I tried just installing py2exe (via the downloadable installer), but of course that doesn't work because it uses the system-level python, which doesn't have the dependencies for my script installed. It needs to use the virtualenv - but there doesn't seem to be such an option.

I did manage to get bbfreeze to work, but it outputs a dist folder crammed with files, and I just want a simple EXE file (one file) for my simple script, and I understand Py2Exe can do this.

tl;dr: How do I run Py2Exe within the context of a virtualenv so it correctly imports dependencies?

like image 878
ezuk Avatar asked Nov 20 '13 18:11

ezuk


1 Answers

You can do that this way:

  1. Activate your virtualenv and then ...
  2. easy_install py2exe-0.6.9.win32-py2.7.exe
like image 71
hexo Avatar answered Sep 22 '22 13:09

hexo