docs
docs copied to clipboard
Docs: update sample application initiation in venv
Until now, readers would install 'Flask' on their main system python environment, freeze their entire packages, and grep only the 'Flask' package! So they would be missing all the other dependencies in their requirements file.
With this commit, a better practice is followed. First, create a clean virtual environment, then install 'Flask' and freeze everything into the requirements file.
Also, I recommend using 'python3 -m pip freeze' instead of 'pip3 freeze' while in the virtual environment. This is because sometimes hidden quirks of 'pip' will ignore the actiavted environment and freeze the entire python packages in the system (e.g. in ArchLinux).
Proposed changes
Related issues (optional)
Deploy Preview for docsdocker ready!
Built without sensitive environment variables
Name | Link |
---|---|
Latest commit | 51558f69aff92f55f584fac7ce072eb33c928ca5 |
Latest deploy log | https://app.netlify.com/sites/docsdocker/deploys/630b10e269acbd00086f261a |
Deploy Preview | https://deploy-preview-15506--docsdocker.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
Deploy Preview for docsdocker ready!
Name | Link |
---|---|
Latest commit | e2e530973c4a60455c75c483af64f7f752bb0818 |
Latest deploy log | https://app.netlify.com/sites/docsdocker/deploys/6336ed0fb70e4b000871887a |
Deploy Preview | https://deploy-preview-15506--docsdocker.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
Hi @pedramardakani, in the snippet below, I think the first two commands are redundant.
$ cd /path/to/python-docker
$ source .venv/bin/activate
(.venv) $ python3 -m flask run
like if the user/person is following along the documentation, he/she would already be in the activated environment.
Hi @pedramardakani, in the snippet below, I think the first two commands are redundant.
$ cd /path/to/python-docker $ source .venv/bin/activate (.venv) $ python3 -m flask run
like if the user/person is following along the documentation, he/she would already be in the activated environment.
Hey there @PMohanJ 👋 As you said, this is a redundancy if the user is following along in the same terminal window. But as the previous sentence in the documentations suggests, the user might open up a new terminal. In that case, some that are not very well acquainted with python virtual environments, might get confused that why their flask application is not running. This is here to save some rookie-mistake debugging time, and act as a reminder.
But feel free to remove it if you think that suits the documentation better 🙌
Hi @pedramardakani
But as the previous sentence in the documentations suggests, the user might open up a new terminal. In that case, some that are not very well acquainted with python virtual environments, might get confused that why their flask application is not running.
Considering the above case, as you said; it's better to leave it like that. Good day!