- Python installé
- VS Code installé
- Extension Python VS Code
- Environnement virtuel créé
- Librairies installées
- Premier script testé
- Va sur https://www.python.org/downloads/
- Télécharge Python 3.10 ou plus récent
- IMPORTANT : Coche "Add Python to PATH" pendant l'installation !
- Vérifie l'installation :
python --version
# ou
python3 --version# Avec Homebrew (recommandé)
brew install python3
# Vérifier
python3 --versionsudo apt update
sudo apt install python3 python3-pip python3-venv
# Vérifier
python3 --version- Télécharge depuis https://code.visualstudio.com/
- Installe normalement
- Lance VS Code
- Ouvre VS Code
- Clique sur l'icône Extensions (carré avec 4 carrés) ou
Ctrl+Shift+X - Cherche "Python"
- Installe l'extension officielle de Microsoft
- Python Indent (facilite l'indentation)
- Pylance (meilleure autocomplétion)
- Jupyter (pour notebooks si besoin plus tard)
- Error Lens (voir les erreurs inline)
- Code Runner (exécuter code rapidement)
roadmap-nlp/
│
├── semaine1-bow/
│ ├── bow_from_scratch.py
│ ├── search_engine_v01.py
│ └── tests/
│
├── semaine2-tfidf/
│ ├── tfidf_from_scratch.py
│ ├── search_engine_v02.py
│ └── tests/
│
├── semaine3-word2vec/
│ ├── word2vec_basics.py
│ ├── search_engine_v03.py
│ └── models/
│
└── data/
└── corpus.txt
Option 1 : Via terminal/cmd
# Crée le dossier principal
mkdir roadmap-nlp
cd roadmap-nlp
# Crée les sous-dossiers
mkdir semaine1-bow semaine2-tfidf semaine3-word2vec data
# Crée un fichier test
touch semaine1-bow/bow_from_scratch.pyOption 2 : Via VS Code
- Ouvre VS Code
Fichier > Ouvrir le dossier(ouCtrl+K Ctrl+O)- Crée un nouveau dossier
roadmap-nlp - Sélectionne ce dossier
- Crée les sous-dossiers avec le bouton "Nouveau dossier"
Un environnement virtuel isole tes librairies Python pour ce projet. Évite les conflits !
Dans VS Code, ouvre un terminal :
Terminal > Nouveau Terminal(ouCtrl+`)
Puis tape :
# Windows
python -m venv venv
# Mac/Linux
python3 -m venv venvCela crée un dossier venv/ dans ton projet.
Windows (CMD):
venv\Scripts\activateWindows (PowerShell):
venv\Scripts\Activate.ps1Mac/Linux:
source venv/bin/activateTu sais que c'est activé quand tu vois (venv) avant ton prompt !
(venv) C:\Users\...\roadmap-nlp>Ctrl+Shift+P(ouvre la palette de commandes)- Tape : "Python: Select Interpreter"
- Choisis celui qui contient
venv(ex:.\venv\Scripts\python.exe)
Avec ton environnement virtuel activé :
pip install numpypip install numpy scikit-learn matplotlibpip install numpy scikit-learn matplotlib gensimpip install numpy scikit-learn matplotlib gensim nltkpip freeze > requirements.txtPlus tard, tu pourras réinstaller tout avec :
pip install -r requirements.txt# test.py
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
print("✅ NumPy version:", np.__version__)
# Test rapide
documents = ["le chat dort", "le chien aboie"]
vectorizer = TfidfVectorizer()
tfidf = vectorizer.fit_transform(documents)
print("✅ Sklearn fonctionne!")
print(f"✅ Matrice TF-IDF shape: {tfidf.shape}")
print("\n🎉 Tout est prêt ! Tu peux commencer la roadmap.")Option 1 : Dans le terminal
python test.pyOption 2 : Dans VS Code
- Clique droit sur le fichier > "Run Python File in Terminal"
- Ou appuie sur le bouton
▶️ en haut à droite
Résultat attendu :
✅ NumPy version: 1.24.x
✅ Sklearn fonctionne!
✅ Matrice TF-IDF shape: (2, 4)
🎉 Tout est prêt ! Tu peux commencer la roadmap.
Crée un dossier .vscode dans ton projet, puis un fichier settings.json :
{
"python.defaultInterpreterPath": "${workspaceFolder}/venv/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "autopep8",
"editor.formatOnSave": true,
"python.terminal.activateEnvironment": true,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000
}# Environnement virtuel
venv/
env/
# Python
__pycache__/
*.pyc
*.pyo
*.egg-info/
.pytest_cache/
# VS Code
.vscode/
.DS_Store
# Modèles (gros fichiers)
*.model
*.bin
Fichier > Préférences > Configurer les extraits de code utilisateur- Choisis "Python"
- Ajoute :
{
"Python Script Header": {
"prefix": "pyheader",
"body": [
"# ${1:filename}.py",
"# ${2:Description}",
"",
"import numpy as np",
"",
"def main():",
" ${3:pass}",
"",
"",
"if __name__ == '__main__':",
" main()"
],
"description": "Header for Python scripts"
}
}Maintenant, tape pyheader et appuie sur Tab pour avoir un template !
Crée ton premier fichier et colle ce code de démarrage :
# semaine1-bow/bow_from_scratch.py
# Implémentation de Bag of Words from scratch
def create_vocabulary(documents):
"""
Crée le vocabulaire à partir d'une liste de documents
Args:
documents: liste de strings ["doc1", "doc2", ...]
Returns:
liste de mots uniques, triée alphabétiquement
"""
# TODO : À compléter !
all_words = []
for doc in documents:
words = doc.lower().split()
all_words.extend(words)
vocabulary = sorted(set(all_words))
return vocabulary
def document_to_vector(document, vocabulary):
"""
Transforme un document en vecteur BoW
Args:
document: string
vocabulary: liste de mots
Returns:
liste de nombres (vecteur)
"""
# TODO : À compléter !
pass
def main():
"""
Fonction principale pour tester
"""
# Test documents
documents = [
"le chat dort sur le tapis",
"le chien aboie dans le jardin",
"le chat mignon joue"
]
# Créer vocabulaire
vocab = create_vocabulary(documents)
print("Vocabulaire:", vocab)
print(f"Taille: {len(vocab)} mots")
if __name__ == "__main__":
main()python semaine1-bow/bow_from_scratch.pySolution : Python n'est pas dans le PATH.
- Windows : Réinstalle Python et coche "Add to PATH"
- Ou utilise
python3au lieu depython
python -m pip install [package]Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserCtrl+Shift+P- "Python: Select Interpreter"
- Choisis celui dans
venv/
Vérifie que :
- L'environnement virtuel est activé (
(venv)visible) - Les packages sont installés :
pip list - VS Code utilise le bon interpréteur
Avant de commencer la roadmap, vérifie que tu as :
- Python fonctionne :
python --version - VS Code installé avec extension Python
- Environnement virtuel créé et activé
- Librairies installées :
pip listmontre numpy, sklearn, etc. - Structure de dossiers créée
-
test.pys'exécute sans erreur - Premier script
bow_from_scratch.pycréé
Tu peux maintenant :
- Ouvrir la roadmap (avec Obsidian/Typora/StackEdit)
- Ouvrir VS Code avec ton projet
- Commencer SEMAINE 1 - JOUR 1 !
# Activer environnement
# Windows CMD:
venv\Scripts\activate
# Mac/Linux:
source venv/bin/activate
# Installer une librairie
pip install [nom-package]
# Exécuter un script
python mon_script.py
# Désactiver environnement
deactivate- Documentation Python : https://docs.python.org/fr/3/
- VS Code Python Tutorial : https://code.visualstudio.com/docs/python/python-tutorial
- Real Python (tutoriels) : https://realpython.com/
- Ouvre toujours VS Code via le terminal après avoir activé l'environnement
- Sauvegarde régulièrement (VS Code le fait automatiquement si configuré)
- Utilise Git pour versioner ton code (optionnel mais recommandé)
- Teste après chaque fonction écrite
- N'hésite pas à utiliser
print()partout pour déboguer !
Bonne chance pour la roadmap ! 🎉
Si tu rencontres un problème, note exactement :
- La commande que tu as tapée
- Le message d'erreur complet
- Ce que tu as déjà essayé
Et on pourra déboguer ensemble ! 😊