Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a pyinstaller executable that uses virtualenv imported modules

So, the title basically covers my question. I've created a project using virtualenv, e.g. I have to

source ./env/bin/activate 

to run my script.

When I try creating an executable using:

pyinstaller --onefile <myscript.py>

None of the virtualenv packages are included; just the ones that are installed globally. I have a requirements.txt file that contains all of the modules I need. Is there a way to have pyinstaller point to that for the needed modules, or is there another way?

like image 356
Topher Sikorra Avatar asked Mar 18 '19 19:03

Topher Sikorra


People also ask

Does PyInstaller work with virtual environment?

If you're using a virtual environment, remember to activate it before installing PyInstaller . After installation, the pyinstaller binary is located in your virtual environment's bin/ directory, or where your Python executable is located.

Does PyInstaller work with libraries?

PyInstaller does not include libraries that should exist in any installation of this OS. For example in GNU/Linux, it does not bundle any file from /lib or /usr/lib , assuming these will be found in every system.


1 Answers

As Valentino pointed out by looking at How can I create the minimum size executable with pyinstaller?

You have to run PyIntaller from inside the virtual environment:

(venv_test) D:\testenv>pyinstaller
like image 90
Alvaro Rodriguez Scelza Avatar answered Oct 17 '22 18:10

Alvaro Rodriguez Scelza