简体   繁体   中英

How to export python project with virtual environment?

当我们导出python项目(即通过转换为.exe文件)时,我们如何包含我们使用的库,这些库位于字典中的虚拟环境文件夹(“venv”)中。

Don't Confuse between virtual Environment and the executable.

Simple explanation

Executable:

this is for packaging/freezing the code to exe and we can even run the exe in any machine without python also.

exe creation modules:

pyinstaller
py2exe

Virtualenv:

This is for maintaining packages and dependencies. if you are working on multiple python projects you can create multiple environments for managing all the packages independently and you can generate requirements.txt and share with a colleague so they can install project dependency in a single command

You can also generate exe for the project inside the virtualenv.

if you are not using virtualenv then your requirement file will have a lot of junk which you installed earlier for some other project also.

export method:

pip freeze requirements.txt     (Copy the generated file to another machine)
pip install -r requirements.txt (from another machine)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM