Installing Libraries
What are Libraries?
In programming, libraries are collections of pre-written code that provide reusable functions, classes, and methods to perform common tasks. Libraries can significantly simplify your development process by allowing you to leverage existing solutions rather than writing code from scratch. They cover a wide range of functionalities such as data manipulation, machine learning, web development, and more.
Why Do We Need Libraries?
Libraries are essential for several reasons:
- Efficiency: Libraries save time by providing pre-built functions and modules, allowing you to focus on the unique aspects of your project**.
- Reliability: Libraries are often tested and optimized by a large community of developers, ensuring robust and efficient code.
- Consistency: Using libraries promotes consistency in your codebase, making it easier to read, maintain, and collaborate with others.
- Functionality: Libraries offer advanced features and capabilities that would be complex and time-consuming to implement on your own.
Create a Virtual Environment with Miniconda
A virtual environment is an isolated environment that allows you to manage libraries for different projects separately. This is crucial for several reasons:
- Dependency Management: Different projects might require different versions of libraries. Virtual environments allow you to maintain these dependencies without conflicts.
- Project Isolation: Each virtual environment is independent, ensuring that changes in one project do not affect another.
- Reproducibility: Virtual environments help in replicating the development environment, making it easier to share and collaborate on projects.
- Cleaner System: By using virtual environments, you avoid installing packages globally, keeping your base system clean and organized.
Creating a virtual environment ensures that your projects remain manageable, reproducible, and free from dependency conflicts.
Now let’s create a virtual environment with miniconda:
- Open your miniconda powershell.
- Create a new virtual environment by running the following command:
conda create -n myenv python=3.9
Replace
myenv
with the name you want for your environment and3.9
with the desired Python version. - Activate you new virtual environment calling its name and download necessary libraries for the course:
conda activate myenv
- Now you can install th libraries needed inside that virtual environment:
conda install numpy conda install pandas conda install matplotlib
These libraries are needed for numerical computations and array handling (
NumPy
), data manipulation and analysis (pandas
), and creating visualizations (Matplotlib
).