Skip to content

Commit 1f3db84

Browse files
harish-s-developerntroghcwebster-99
authored
Added new Managing dependencies section, fixed one typo (#7617)
* Added new Managing dependencies section, fixed one typo * Apply suggestions from code review Co-authored-by: Nick Trogh <[email protected]> * Apply suggestions from code review Co-authored-by: Courtney Webster <[email protected]> * Review comment changes --------- Co-authored-by: Nick Trogh <[email protected]> Co-authored-by: Courtney Webster <[email protected]>
1 parent 19ed99a commit 1f3db84

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

docs/python/python-tutorial.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ For a Data Science focused tutorial with Python, check out our [Data Science sec
2020

2121
## Prerequisites
2222

23-
To successfully complete this tutorial, you need to first setup your Python development environment. Specifically, this tutorial requires:
23+
To successfully complete this tutorial, you need to first set up your Python development environment. Specifically, this tutorial requires:
2424

2525
- [Python 3](/docs/python/python-tutorial.md#install-a-python-interpreter)
2626
- [VS Code](https://code.visualstudio.com/)
@@ -261,6 +261,34 @@ To install the required packages in your virtual environment, enter the followin
261261

262262
1. Now, rerun the program, with or without the debugger, to view the output!
263263

264+
### Managing dependencies across environments
265+
When working on Python projects, it’s essential to manage your dependencies effectively. One useful tip is to use the `pip freeze > requirements.txt` command. This command helps you create a `requirements.txt` file that lists all the packages installed in your virtual environment. This file can then be used to recreate the same environment elsewhere.
266+
267+
Follow these steps to create a `requirements.txt` file:
268+
1. Activate your virtual environment, if you haven’t already.
269+
270+
```bash
271+
source venv/bin/activate # On macOS/Linux
272+
```
273+
274+
```powershell
275+
.\venv\Scripts\activate # On Windows
276+
```
277+
278+
2. Generate the `requirements.txt` file.
279+
280+
```powershell
281+
pip freeze > requirements.txt
282+
```
283+
284+
You can now use the newly generated `requirements.txt` file to install dependencies in another environment. Furthermore, you can continue to add dependencies to it as your project may grow in complexity.
285+
286+
```powershell
287+
pip install -r requirements.txt
288+
```
289+
290+
By following these steps, you ensure that your project dependencies are consistent across different environments, making it easier to collaborate with others and deploy your project.
291+
264292
Congrats on completing the Python tutorial! During the course of this tutorial, you learned how to create a Python project, create a virtual environment, run and debug your Python code, and install Python packages. Explore additional resources to learn how to get the most out of Python in Visual Studio Code!
265293

266294
## Next steps

0 commit comments

Comments
 (0)