×
1 Choose EITC/EITCA Certificates
2 Learn and take online exams
3 Get your IT skills certified

Confirm your IT skills and competencies under the European IT Certification framework from anywhere in the world fully online.

EITCA Academy

Digital skills attestation standard by the European IT Certification Institute aiming to support Digital Society development

LOG IN TO YOUR ACCOUNT

CREATE AN ACCOUNT FORGOT YOUR PASSWORD?

FORGOT YOUR PASSWORD?

AAH, WAIT, I REMEMBER NOW!

CREATE AN ACCOUNT

ALREADY HAVE AN ACCOUNT?
EUROPEAN INFORMATION TECHNOLOGIES CERTIFICATION ACADEMY - ATTESTING YOUR PROFESSIONAL DIGITAL SKILLS
  • SIGN UP
  • LOGIN
  • INFO

EITCA Academy

EITCA Academy

The European Information Technologies Certification Institute - EITCI ASBL

Certification Provider

EITCI Institute ASBL

Brussels, European Union

Governing European IT Certification (EITC) framework in support of the IT professionalism and Digital Society

  • CERTIFICATES
    • EITCA ACADEMIES
      • EITCA ACADEMIES CATALOGUE<
      • EITCA/CG COMPUTER GRAPHICS
      • EITCA/IS INFORMATION SECURITY
      • EITCA/BI BUSINESS INFORMATION
      • EITCA/KC KEY COMPETENCIES
      • EITCA/EG E-GOVERNMENT
      • EITCA/WD WEB DEVELOPMENT
      • EITCA/AI ARTIFICIAL INTELLIGENCE
    • EITC CERTIFICATES
      • EITC CERTIFICATES CATALOGUE<
      • COMPUTER GRAPHICS CERTIFICATES
      • WEB DESIGN CERTIFICATES
      • 3D DESIGN CERTIFICATES
      • OFFICE IT CERTIFICATES
      • BITCOIN BLOCKCHAIN CERTIFICATE
      • WORDPRESS CERTIFICATE
      • CLOUD PLATFORM CERTIFICATENEW
    • EITC CERTIFICATES
      • INTERNET CERTIFICATES
      • CRYPTOGRAPHY CERTIFICATES
      • BUSINESS IT CERTIFICATES
      • TELEWORK CERTIFICATES
      • PROGRAMMING CERTIFICATES
      • DIGITAL PORTRAIT CERTIFICATE
      • WEB DEVELOPMENT CERTIFICATES
      • DEEP LEARNING CERTIFICATESNEW
    • CERTIFICATES FOR
      • EU PUBLIC ADMINISTRATION
      • TEACHERS AND EDUCATORS
      • IT SECURITY PROFESSIONALS
      • GRAPHICS DESIGNERS & ARTISTS
      • BUSINESSMEN AND MANAGERS
      • BLOCKCHAIN DEVELOPERS
      • WEB DEVELOPERS
      • CLOUD AI EXPERTSNEW
  • FEATURED
  • SUBSIDY
  • HOW IT WORKS
  •   IT ID
  • ABOUT
  • CONTACT
  • MY ORDER
    Your current order is empty.
EITCIINSTITUTE
CERTIFIED

How to configure specific Python environment with Jupyter notebook?

by Deepak Balmiki / Monday, 02 June 2025 / Published in Artificial Intelligence, EITC/AI/GCML Google Cloud Machine Learning, Further steps in Machine Learning, Working with Jupyter

Configuring a specific Python environment for use with Jupyter Notebook is a fundamental practice in data science, machine learning, and artificial intelligence workflows, particularly when leveraging Google Cloud Machine Learning (AI Platform) resources. This process ensures reproducibility, dependency management, and isolation of project environments. The following comprehensive guide addresses the configuration steps, rationale, and best practices for creating and integrating a Python environment with Jupyter Notebook, with a focus on practical application within the context of machine learning on cloud-based infrastructure.

1. Understanding Python Environments

A Python environment is an isolated workspace that allows users to install and manage packages independently of the system-wide Python installation. This isolation is vital for managing dependencies for different projects, avoiding version conflicts, and ensuring that development and production environments remain consistent.

Common tools for creating isolated Python environments include:
– virtualenv: Creates lightweight Python environments.
– venv: The standard library module for creating virtual environments (Python 3.3+).
– conda: A package, dependency, and environment manager that supports multiple languages.

For machine learning projects on Google Cloud, `virtualenv` and `conda` are widely used, with `conda` often preferred for its ease in managing both Python and non-Python dependencies.

2. Creating a Python Environment

Using virtualenv

1. Install virtualenv (if not present):

bash
   pip install virtualenv
   

2. Create a new environment:

bash
   virtualenv my_ml_env
   

3. Activate the environment:
– On Linux/macOS:

bash
     source my_ml_env/bin/activate
     

– On Windows:

bash
     my_ml_env\Scripts\activate
     

4. Verify activation:
The shell prompt changes to indicate the active environment (e.g., `(my_ml_env)`).

Using conda

1. Create a new environment with a specific Python version:

bash
   conda create -n my_ml_env python=3.10
   

2. Activate the environment:

bash
   conda activate my_ml_env
   

3. List environments (optional):

{{EJS35}}

3. Installing Required Packages

After activating the desired environment, install necessary packages, such as `jupyter`, machine learning libraries (`scikit-learn`, `tensorflow`, `pandas`, etc.), and any other dependencies. Example with pip:
bash
pip install jupyter numpy pandas scikit-learn matplotlib

Example with conda:

bash
conda install jupyter numpy pandas scikit-learn matplotlib

For GPU support (e.g., TensorFlow-GPU), specify the appropriate versions:

{{EJS38}}

4. Integrating the Environment with Jupyter Notebook

To use the newly created environment as a Jupyter kernel, the `ipykernel` package must be installed within the environment. This enables Jupyter Notebook to recognize and launch kernels with the exact dependencies and Python version specified. 1. Install ipykernel in the active environment:
bash
   pip install ipykernel
   

or

bash
   conda install ipykernel
   

2. Create a new Jupyter kernel for the environment:

bash
   python -m ipykernel install --user --name my_ml_env --display-name "Python (my_ml_env)"
   

- `--user`: Installs the kernel for the current user.
- `--name`: Internal identifier for the kernel.
- `--display-name`: The name shown in Jupyter Notebook's kernel selection menu.

3. Verify kernel installation:
Launch Jupyter Notebook:

bash
   jupyter notebook
   

Under "Kernel" > "Change kernel", "Python (my_ml_env)" should appear as an option.

5. Example Workflow

Step 1: Create and activate environment
{{EJS43}}
Step 2: Install packages
{{EJS44}}
Step 3: Add environment as Jupyter kernel
{{EJS45}}
Step 4: Start Jupyter Notebook and select kernel
bash
jupyter notebook

- In the notebook interface, select "Kernel" > "Change Kernel" > "Python (GCP ML Env)".

Step 5: Run code in the isolated environment
python
import sys
import tensorflow as tf
print(sys.executable)
print(tf.__version__)

- This verifies that your notebook is running in the intended environment and with the appropriate package versions.

6. Managing Multiple Environments

When working on multiple machine learning projects with differing dependencies or Python versions, repeat the process above for each project. Each environment should be independently created, activated, and registered as a Jupyter kernel.

To remove a Jupyter kernel:

bash
jupyter kernelspec uninstall <kernel_name>

To remove a conda environment:

{{EJS49}}

7. Using Environments with Google Cloud Machine Learning

Google Cloud’s AI Platform Notebooks allow users to launch JupyterLab or Jupyter Notebook servers on customizable virtual machine instances. These instances can be further configured via SSH or terminal access to create and manage custom Python environments as described above. Best Practice: - Use startup scripts or Docker containers to automate environment setup on Google Cloud instances for consistent reproducibility. - For advanced isolation, consider using Docker containers with Jupyter Notebook and the required environment pre-installed.

8. Exporting and Sharing Environments

To share environments or ensure reproducibility:
With pip (virtualenv or venv)
Export:
bash
pip freeze > requirements.txt

Import:

{{EJS51}}
With conda
Export:
bash
conda env export > environment.yml

Import:

bash
conda env create -f environment.yml

Sharing the `requirements.txt` or `environment.yml` file alongside your Jupyter notebooks allows collaborators to recreate the exact environment.

9. Troubleshooting Common Issues

- Kernel Not Appearing: Ensure `ipykernel` is installed in the active environment and that `python -m ipykernel install` has been executed.
- Dependency Conflicts: Use virtual environments or conda environments to avoid version mismatches.
- GPU Support: Install the correct versions of libraries (e.g., TensorFlow-GPU) and verify CUDA/cuDNN installation.
- Cloud Permissions: When working on Google Cloud, ensure sufficient permissions to install packages and create environments.

10. Best Practices and Recommendations

- Isolate environments per project to prevent dependency conflicts and improve reproducibility.
- Pin package versions in your environment files for exact replication.
- Regularly update environments and test with your code to ensure compatibility.
- Document environment setup steps in project documentation.

11. Example: Full Configuration on Google Cloud AI Platform Notebook

Suppose a user is working on a machine learning project that requires TensorFlow 2.9, scikit-learn 1.1, and pandas 1.4, and the project is hosted on a Google Cloud AI Platform Notebook. The steps might be:

1. Open a Terminal in the JupyterLab interface.
2. Create a new conda environment:

bash
   conda create -n mygcpml python=3.8
   conda activate mygcpml
   

3. Install required packages:

bash
   conda install tensorflow=2.9 scikit-learn=1.1 pandas=1.4 ipykernel
   

4. Add the environment as a Jupyter kernel:

bash
   python -m ipykernel install --user --name mygcpml --display-name "Python (My GCP ML)"
   

5. Restart JupyterLab/Notebook and select the new kernel.
6. Verify environment:

python
   import tensorflow as tf
   import sklearn
   import pandas as pd
   print(tf.__version__, sklearn.__version__, pd.__version__)
   

This approach ensures that experiments, models, and data analysis are run in a controlled, reproducible, and isolated environment, minimizing the likelihood of "works on my machine" issues and facilitating cloud-based collaboration.

Other recent questions and answers regarding EITC/AI/GCML Google Cloud Machine Learning:

  • Is the so called part of "Inference" equivalent to the description in the step-by-step process of machine learning described as "evaluating, iterating, improving"?
  • What are some common AI/ML algorithms to be used on the processed data?
  • How Keras models replace TensorFlow estimators?
  • How to use TensorFlow Serving?
  • What is Classifier.export_saved_model and how to use it?
  • Why is regression frequently used as a predictor?
  • Are Lagrange multipliers and quadratic programming techniques relevant for machine learning?
  • Can more than one model be applied during the machine learning process?
  • Can Machine Learning adapt which algorithm to use depending on a scenario?
  • What is the simplest route to most basic didactic AI model training and deployment on Google AI Platform using a free tier/trial using a GUI console in a step-by-step manner for an absolute begginer with no programming background?

View more questions and answers in EITC/AI/GCML Google Cloud Machine Learning

More questions and answers:

  • Field: Artificial Intelligence
  • Programme: EITC/AI/GCML Google Cloud Machine Learning (go to the certification programme)
  • Lesson: Further steps in Machine Learning (go to related lesson)
  • Topic: Working with Jupyter (go to related topic)
Tagged under: Artificial Intelligence, Environment Management, Google Cloud, Jupyter, Machine Learning, Python
Home » Artificial Intelligence / EITC/AI/GCML Google Cloud Machine Learning / Further steps in Machine Learning / Working with Jupyter » How to configure specific Python environment with Jupyter notebook?

Certification Center

USER MENU

  • My Account

CERTIFICATE CATEGORY

  • EITC Certification (105)
  • EITCA Certification (9)

What are you looking for?

  • Introduction
  • How it works?
  • EITCA Academies
  • EITCI DSJC Subsidy
  • Full EITC catalogue
  • Your order
  • Featured
  •   IT ID
  • EITCA reviews (Medium publ.)
  • About
  • Contact

EITCA Academy is a part of the European IT Certification framework

The European IT Certification framework has been established in 2008 as a Europe based and vendor independent standard in widely accessible online certification of digital skills and competencies in many areas of professional digital specializations. The EITC framework is governed by the European IT Certification Institute (EITCI), a non-profit certification authority supporting information society growth and bridging the digital skills gap in the EU.

Eligibility for EITCA Academy 80% EITCI DSJC Subsidy support

80% of EITCA Academy fees subsidized in enrolment by

    EITCA Academy Secretary Office

    European IT Certification Institute ASBL
    Brussels, Belgium, European Union

    EITC / EITCA Certification Framework Operator
    Governing European IT Certification Standard
    Access contact form or call +32 25887351

    Follow EITCI on X
    Visit EITCA Academy on Facebook
    Engage with EITCA Academy on LinkedIn
    Check out EITCI and EITCA videos on YouTube

    Funded by the European Union

    Funded by the European Regional Development Fund (ERDF) and the European Social Fund (ESF) in series of projects since 2007, currently governed by the European IT Certification Institute (EITCI) since 2008

    Information Security Policy | DSRRM and GDPR Policy | Data Protection Policy | Record of Processing Activities | HSE Policy | Anti-Corruption Policy | Modern Slavery Policy

    Automatically translate to your language

    Terms and Conditions | Privacy Policy
    EITCA Academy
    • EITCA Academy on social media
    EITCA Academy


    © 2008-2025  European IT Certification Institute
    Brussels, Belgium, European Union

    TOP
    Chat with Support
    Chat with Support
    Questions, doubts, issues? We are here to help you!
    End chat
    Connecting...
    Do you have any questions?
    Do you have any questions?
    :
    :
    :
    Send
    Do you have any questions?
    :
    :
    Start Chat
    The chat session has ended. Thank you!
    Please rate the support you've received.
    Good Bad