Configuring PyCharm for Hugging Face and Deep Learning Frameworks




๐Ÿงช Scientific Report: Configuring PyCharm for Hugging Face and Deep Learning Frameworks

๐Ÿ“ Abstract

This report outlines the procedure for configuring a Python development environment in PyCharm for machine learning workflows involving Hugging Face, PyTorch, TensorFlow, and Transformers. The environment was initially created and configured via the terminal, and later integrated into PyCharm for streamlined development.

1. ๐Ÿงฑ Environment Setup via Terminal

1.1 Project Directory

/mnt/wwn-part2/python/hugging_face

1.2 Virtual Environment Creation

python3 -m venv venv
source venv/bin/activate

1.3 Package Installation

pip install torch torchvision torchaudio
pip install tensorflow
pip install transformers
pip install datasets

1.4 Environment Variable Configuration

export HF_HOME="/mnt/wwn-part2/python/hugging_face/.cache/huggingface"
export HF_HUB_CACHE="$HF_HOME/hub"

These variables ensure that downloaded models and datasets are stored in a centralized location.

2. ๐Ÿง  PyCharm Integration

2.1 Linking the Existing Virtual Environment

In PyCharm:

  • Navigate to File > Settings > Project: [project_name] > Python Interpreter
  • Click the ⚙️ icon > Add...
  • Choose Virtualenv Environment > Existing environment
  • Select the interpreter at:
    /mnt/wwn-part2/python/hugging_face/venv/bin/python

2.2 Configuring Environment Variables in PyCharm

  • Go to Run > Edit Configurations
  • Select the desired script or create a new configuration
  • In the Environment Variables field, add:
    HF_HOME=/mnt/wwn-part2/python/hugging_face/.cache/huggingface;HF_HUB_CACHE=/mnt/wwn-part2/python/hugging_face/.cache/huggingface/hub

(Use : instead of ; on Linux/macOS if needed)

3. ๐Ÿงช Framework Validation

To validate the setup, the following Python script was executed:

import torch
import tensorflow as tf
from transformers import pipeline

print("Torch version:", torch.__version__)
print("TensorFlow version:", tf.__version__)
print("Sentiment analysis:", pipeline("sentiment-analysis")("I love PyCharm!"))

Expected output confirms successful installation and environment configuration.

✅ Conclusion

This setup ensures a reproducible and efficient development environment for deep learning workflows using Hugging Face and PyCharm. By configuring the environment externally and linking it to PyCharm, developers maintain flexibility while benefiting from IDE features.

Comments