Virtual env examples#6
Conversation
magdapoppins
left a comment
There was a problem hiding this comment.
Looks mainly good! I added some thoughts. Could you do something to the commit history as well, unless you plan on squashing it in the merge?
|
|
||
| ## Why to use virtual environment? | ||
| To isolate environment from the global environments and having same Python pip libraries as the project obtains is what venv is mainly used for. | ||
| Sometimes the project may require specific libraries to work as syntax of the libraries may change or they are depended on another older libraries. |
There was a problem hiding this comment.
Maybe one could also write some example/more explanations like:
- What is the difference if I do pip install inside a virtual environment contra without one?
- What are libraries? What is an environment? (Really hard questions to answer in a simple way, actually!)
There was a problem hiding this comment.
Good points to make bit more simpler level explanations. :)
There was a problem hiding this comment.
Not sure if the picture shows in commits, but at least there are some visuals about versions :)
https://github.com/Naapi/beginners-python-weather/tree/master/HowToVenv
|
|
||
| Create a venv | ||
| ``` | ||
| py -m venv venv |
There was a problem hiding this comment.
Quite unusual to have python3 aliased as py?
There was a problem hiding this comment.
Windows magic it seems for pointing out the file path. Gives error with python/3 alias, but guess there are some workarounds for that. Tested it working locally
|
|
||
| ### Install libraries from requirements.txt | ||
|
|
||
| Commonly `requirements.txt` is used for listing needed libraries and versions for the projectvirtual environment. When creating a new venv, the libraries needed for the project are needed to be installed with following: |
There was a problem hiding this comment.
"projectvirtual". Ahaa 👍
| * Format strings using [f-strings](https://realpython.com/python-f-strings/#f-strings-a-new-and-improved-way-to-format-strings-in-python) | ||
| * Use [urllib](https://docs.python.org/3/howto/urllib2.html) to make requests to the API | ||
| * Create a [virtualenv](https://docs.python.org/3/library/venv.html) for managing dependencies | ||
| * Create a [virtualenv](https://docs.python.org/3/library/venv.html) for managing dependencies // More virtual environment examples [here](/HowToVenv) |
There was a problem hiding this comment.
Does this link work? 👀 Or does it need to point at the readme in /HowToVenv/README.md?
There was a problem hiding this comment.
Looks mainly good! I added some thoughts. Could you do something to the commit history as well, unless you plan on squashing it in the merge?
I will take a second look for that. Tried to squash them, but things went horribly wrong :D
There was a problem hiding this comment.
Does this link work? 👀 Or does it need to point at the readme in /HowToVenv/README.md?
Yep, it will point to the Folder and folder itself shows the README.md like the Repo's front page readme
There was a problem hiding this comment.
I feel ya! You could try
git reset HEAD~5 (or how many steps backward you wanna go)
git add .
git commit -m "My new fancy commit
There was a problem hiding this comment.
I can try that, tried with rebase after midnight... soo maybe with more fresh mind it will work :D
#4 Added some examples of virtual environment with different OS :)