How To Set Up Your Data Science Virtual Environment

Turgutguvenc
2 min readMay 22, 2021

--

To begin with, I assume you already installed Python and Anaconda distribution. Anaconda is an incredible collection of scientific Python packages, tools, resources, and IDEs. This package includes many important tools that a Data Scientist can use for amazing projects. Anaconda's individual edition is free and open source. This makes working with Anaconda accessible and easy. Just go to the website and download the distribution.

Why do we need a virtual environment? The virtual environment gives us an isolated environment, thanks to this feature we can use a specific Python version or specific package.

First, the different projects may require different requirements. Thus by creating a new virtual environment, you can only use the libraries required by your projects. So that you can create a private environment for your projects. Hence it allows running projects independently from each other.

Second, your project may require a specific version of packages or libraries. For example, you have Python 3.8 of the versions of the Python but your project requires you to use Python 2.8 so, the virtual environment comes to help for this kind of specific needs. So that this kind of requirement can’t affect any other projects.

Virtual Environment Creation and Management Tools

- venv (Part of the standard library)
- virtualenv (Widely-used)
- pipenv (High-level interface)
- conda (Not only for Python)

What is Dependency Management?

in terms of the virtual environment, dependency management is the process of managing all of these interrelated libraries and packages to ensure that your overall project completes successfully. For example, the Pandas library has been created on top of the Numpy library in the Python world. If we use the Pandas without download Numpy its will give us an error. I showed you above the virtual environment creation and management tools can help us in this kind of situation so they can download all the libraries associated with the libraries that we will use in our project, without us needing to specify. This makes things very easy for us.

Managing Packages with pip and conda

You can install, upgrade, and remove packages using a program called pip in your shell or using conda in Anaconda Prompt. By default, pip and conda will install packages from the Python Package Index, <https://pypi.org>.

conda: package and venv management tool(anaconda repository)

I am going to show you step by step the process. Let's jump to the Anaconda Prompt ;

Creating Virtual Environment

  • Additionally, if you don’t state the specific version of packages it will download the latest version of the package.

Activating, Deactivating Virtual Environment

Package Install, Update, Search, Delete From Virtual Environment

Export and Import Packages

Thanks for reading. Please let me know if you have any feedback.

--

--

Turgutguvenc
Turgutguvenc

Written by Turgutguvenc

I am a Data Analyst, and Machine Learning, Big Data enthusiast.

No responses yet