You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/appendix/index.md
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -348,3 +348,70 @@ code .
348
348
```
349
349
350
350
Once VS Code is open, you can create Jupyter notebooks directly in the editor and run them with the full notebook experience. You should now be able to pick up with the [VS Code tutorial](../notebook.md) and start working from there.
351
+
352
+
## Troubleshooting Python Environments and Kernels
353
+
354
+
If you're experiencing issues with importing packages or running code, the problem is often related to Python environment or kernel selection. Here are the most common issues and solutions:
355
+
356
+
### "ModuleNotFoundError: No module named 'pandas'" (or other packages)
357
+
358
+
**Cause**: VS Code is using a different Python environment than where you installed packages.
3. **If any fail**: Reinstall packages in your current environment
413
+
4. **Match VS Code selection**: Ensure interpreter/kernel matches this environment
414
+
415
+
```{tip}
416
+
**Golden Rule**: The Python interpreter (status bar) and Jupyter kernel (notebook top-right) should always point to the same environment where you installed pandas, matplotlib, seaborn, and altair.
Copy file name to clipboardExpand all lines: docs/src/notebook.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,14 @@ Let's start by creating your first Python file. In VS Code:
16
16
17
17
```{note}
18
18
If VS Code prompts you to select a Python interpreter, choose the Python installation you set up in the previous chapter. This tells VS Code which Python environment to use when running your code.
19
+
20
+
**How to select the right interpreter:**
21
+
1. Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on Mac)
22
+
2. Type "Python: Select Interpreter"
23
+
3. Choose the Python installation where you installed packages (pandas, matplotlib, etc.)
24
+
4. Look for the interpreter path that matches your setup (e.g., `.venv`, `anaconda3`, or system Python)
25
+
26
+
The selected interpreter will be shown in the bottom-left status bar of VS Code.
19
27
```
20
28
21
29
Now you're ready to write your first line of Python code. VS Code provides an excellent environment for both learning and professional Python development.
@@ -195,13 +203,47 @@ In addition to interactive Python files, VS Code also supports traditional Jupyt
195
203
196
204
This creates a notebook file where you can add both code and markdown cells, just like in traditional Jupyter environments, but with all the benefits of VS Code's editor features.
197
205
206
+
### Selecting the Right Kernel
207
+
208
+
When you create or open a notebook, you need to select a Python kernel (the engine that runs your code):
209
+
210
+
1.**Automatic Selection**: VS Code may automatically select a kernel based on your workspace
211
+
2.**Manual Selection**: Click the kernel name in the **top-right corner** of the notebook
212
+
3.**Choose Your Kernel**: Select the Python environment where you installed your packages:
213
+
- Look for the same Python path you selected as your interpreter
214
+
- If using uv: Choose the kernel from your project's `.venv` folder
215
+
- If using Anaconda: Choose the anaconda/miniconda kernel
216
+
- The kernel name should show the Python version and environment path
217
+
218
+
4.**Verify Connection**: A green dot next to the kernel name means it's connected and ready to run code
219
+
220
+
### Common Kernel Issues and Solutions
221
+
222
+
**Problem**: "ModuleNotFoundError" when importing pandas or other packages
223
+
224
+
**Solution**:
225
+
1. Check that you're using the correct kernel (top-right of notebook)
226
+
2. Verify packages are installed in that environment
227
+
3. Restart the kernel: Click kernel name → "Restart Kernel"
228
+
229
+
**Problem**: Kernel won't start or keeps disconnecting
230
+
231
+
**Solution**:
232
+
1. Use Command Palette → "Python: Refresh"
233
+
2. Try selecting a different kernel, then switch back
234
+
3. Close and reopen the notebook file
235
+
198
236
The notebook interface in VS Code allows you to:
199
237
- Add code and markdown cells
200
238
- Run cells individually or all at once
201
239
- View rich output including plots and tables
202
240
- Export to various formats
203
241
- Use VS Code's powerful editing features
204
242
243
+
```{tip}
244
+
**Quick Check**: Before running any code, make sure the kernel name in the top-right shows the same Python environment where you installed your packages. This prevents import errors and ensures your code runs correctly.
245
+
```
246
+
205
247
```{note}
206
248
This tutorial includes a complete collection of interactive Jupyter notebooks that you can run directly in VS Code. You can find them in the [Interactive Notebooks](notebooks/index.md) section. These notebooks contain the same content as the tutorial chapters but in an interactive format where you can run the code and see the results immediately.
Copy file name to clipboardExpand all lines: docs/src/notebooks/index.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,15 @@ Make sure you've completed the [VS Code Setup](../vscode_setup.md) before starti
14
14
15
15
1.**Download or clone** this repository to your local machine
16
16
2.**Open VS Code** and navigate to the project folder
17
-
3.**Open any notebook** by clicking on the `.ipynb` files in the `docs/src/notebooks/` directory
18
-
4.**Run cells sequentially** by clicking the play button or pressing `Shift+Enter`
19
-
5.**Experiment** by modifying the code and running your changes
17
+
3.**Select the correct Python environment** in VS Code (see [setup guide](../vscode_setup.md))
18
+
4.**Open any notebook** by clicking on the `.ipynb` files in the `docs/src/notebooks/` directory
19
+
5.**Choose the right kernel** when prompted (should match your Python environment with packages installed)
20
+
6.**Run cells sequentially** by clicking the play button or pressing `Shift+Enter`
21
+
7.**Experiment** by modifying the code and running your changes
22
+
23
+
```{important}
24
+
**Before running any notebook**: Make sure you've selected the correct Python kernel (top-right corner of the notebook). It should be the same environment where you installed pandas, matplotlib, seaborn, and altair. If you see import errors, double-check your kernel selection.
25
+
```
20
26
21
27
Each notebook is self-contained and includes all necessary imports and data loading, so you can start with any chapter that interests you.
Copy file name to clipboardExpand all lines: docs/src/vscode_setup.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -196,4 +196,43 @@ This creates a new `.ipynb` notebook file where you can add cells and run them i
196
196
- Cell execution controls
197
197
- Markdown and code cells
198
198
199
+
## Selecting the Right Python Environment
200
+
201
+
After installing packages, it's crucial to ensure VS Code uses the correct Python environment. This is especially important if you have multiple Python installations.
202
+
203
+
### For Python Files (.py)
204
+
205
+
When working with Python files, VS Code needs to know which Python interpreter to use:
206
+
207
+
1.**Automatic Selection**: VS Code usually detects your Python installation automatically
208
+
2.**Manual Selection**: If needed, press `Ctrl+Shift+P` (or `Cmd+Shift+P`) and type "Python: Select Interpreter"
209
+
3.**Choose Your Environment**: Select the Python installation that has your packages installed:
210
+
- If using uv: Look for the interpreter in your project's `.venv` folder
211
+
- If using Anaconda: Choose the anaconda or miniconda interpreter
212
+
- If using system Python: Choose the global Python installation
213
+
214
+
4.**Verify Selection**: Check the bottom-left status bar - it should show your selected Python version
215
+
216
+
### For Jupyter Notebooks (.ipynb)
217
+
218
+
Notebooks use "kernels" (similar to interpreters) to run code:
219
+
220
+
1.**Initial Kernel Selection**: When you create or open a notebook, VS Code may prompt you to select a kernel
221
+
2.**Manual Kernel Selection**: Click the kernel name in the top-right corner of the notebook to change it
222
+
3.**Choose the Right Kernel**: Select the same Python environment where you installed packages
223
+
4.**Verify Connection**: A green dot next to the kernel name means it's connected and ready
224
+
225
+
### Troubleshooting Environment Issues
226
+
227
+
If your imports don't work or packages aren't found:
228
+
229
+
1.**Check Active Environment**: Verify VS Code is using the environment where you installed packages
230
+
2.**Restart Kernel**: In notebooks, use "Restart Kernel" from the kernel menu
231
+
3.**Refresh Interpreters**: Use Command Palette → "Python: Refresh" to update the interpreter list
232
+
4.**Reinstall Packages**: If still having issues, reinstall packages in the correct environment
233
+
234
+
```{tip}
235
+
**Pro tip**: The status bar (bottom of VS Code) always shows your active Python interpreter. Make sure it matches the environment where you installed your packages!
236
+
```
237
+
199
238
Now you're ready to start learning Python for data analysis! The next chapter will introduce you to working with Jupyter notebooks in VS Code.
0 commit comments