Skip to main content

Command Palette

Search for a command to run...

Need of Virtual Environments in the Python

Debugging and resolving the issues while installing the libraries for Building the AI Model

Updated
โ€ข2 min read
Need of Virtual Environments in the Python

I was building the model in Machine Learning and I got couple of errors while installing the libraries. I debugged and resolved with resources as explained below.

Issue 1: compatibility issue while installing library

I was using the Base environment and while installing the tensorflow library I got the conflicting of the versions of lib/files.

  • When I installed the tensorflow, it brought a newer version of protobuf (7.34.1) which broke Streamlit's compatibility. See below screenshot :-
  • So decided to create the virtual environment to avoid the conflicts .

  • Since then, I am following the best practices to create and use the separate virtual environment (venv)for every new project.

Steps to create venv on Mac Terminal:-

(base) % conda create --name myenv

(base) % conda env list (

base) % conda activate myenv1

(myenv1) % pip3 install ipykernel

(myenv) % python3 -m ipykernel install --user --name myenv --display-name "MyenvKernel"

  • From Jupyter select the MyenvKernel and install the lib peacefully and with no conflict and no compatibility issue:
  • Install the library

Issue2 : Install the scikit-learn library was throwing the syntax error

  • The syntax was correct.

  • Also tried with !pip install scikit-learn but it was showing the same error. There I tried to install it from the backend on terminal.

  • Activate the virtual environment:
    % conda env list

    % conda activate myenv1

    % pip3 install scikit-learn

And the scikit-learn library was installed successfully!

Thank you for reading! ๐Ÿ˜Š

If you found this blog helpful, please like โค๏ธ and Share ๐Ÿ”— it.

Feel free to drop your questions or feedback in the comments below. ๐Ÿ’ฌ

MLOps

Part 1 of 1

MLOps