Using py2exe in virtualenv

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

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

I read and read documents and stackoverflow, and yet I cannot find a simple answer: how to do this? I tried just installing py2exe (via a downloadable installer), but of course this does not work, because it uses python at the system level, which has no dependencies for my script. It should use virtualenv - but there seems to be no such option.

I managed to get bbfreeze to work, but it displays a dist folder filled with files, and I just need a simple EXE file (one file) for my simple script, and I understand that Py2Exe can do this.

tl; dr: How to run Py2Exe in virtualenv context so that it correctly imports dependencies?

+6
source share
2 answers

Installing py2exe in your virtual env should be easy. You will need Visual Studio 2008, the express version should work. Launch the 2008 Command Prompt and activate your virtual env. Go to the directory containing the py2exe source and run python setup.py install . You can verify that py2exe is in the correct environment by trying to import it from an interactive shell. I tested myself earlier today (I had to install virtualenv). It works exactly as expected.

+1
source

You can do it as follows:

  • Activate your virtualenv and then ...
  • easy_install py2exe-0.6.9.win32-py2.7.exe
+8
source

Source: https://habr.com/ru/post/958503/


All Articles