Python - KhepriHuang/Documentation GitHub Wiki

virtaulenv, a tool for creating isolated virtual python environments.

$ pip3 install virtualenv ( install virtualenv, if you have installed, then skip)

$ virtualenv projectname --python=python3.7 (create environment by using virtualenv, keep one project one environment)

$ ./projectname/Scripts/activate (enter virtual environment)

$ pip install –r requirement.txt (optional) First, install library in requirement.txt

$ pip freeze > requirement.txt (dump python library to requirements.txt)

$ deactivate (exit)

pyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules.

$ ./projectname/Scripts/activate (Enter virtualenvironment)

$ pip3 install pyinstaller (install pyinstaller. If you have installed, then skip.)

(projectname) $ pyinstaller -F <file.py> –clean (build code to generate exe)

Finally, you can find the .exe file in the DIST folder.

PS. How to fix ModuleNotFoundError: No module named?

removing any init.py files (empty init.py files are not required in Python 3.3+)

Python debug:

How do I pass command line arguments to Python from VS in debug mode?

Add args in launch.json:

"args": [
    "input2.csv",
    "output2.csv"
],

Debugging Python With ipdb and pdbpp

pip install ipdb

pip install pdbpp

https://serebrov.github.io/html/2018-11-28-python-debugging-with-ipdb-pdbpp.html

⚠️ **GitHub.com Fallback** ⚠️