Replaced VSCode with Positron (and conda with pixi) - #10
Conversation
| ``` | ||
|
|
||
| VSCode directly recognizes the python file extension (.py) and does some suggestions. In the bottom right you can what type of file VSCode thinks you are working in, it also shows a number, most likely 3.12.x if you are following this course in 2025. This number is the python version of the interpreter that is now running, more on this later. In the left there is a column with some buttons. These buttons are, from top to bottom, for: | ||
| You can run the full code by pressing the play button on the top left. Select Run Python File in Terminal to see the output in the Terminal window. |
There was a problem hiding this comment.
So I think here it is good to introduce the concept of project interpreters and explain how to set the pixi interpreter for a project (after pixi init and pixi add python (is this necessary??).
There was a problem hiding this comment.
Okay, so i think if you do:
pixi init MyPackage
cd MyPackage
pixi add python
and then you create a main.py file, Positron should automatically pick the right pixi interpreter.
I'll keep this order in the tutorial
| VSCode directly recognizes the python file extension (.py) and does some suggestions. In the bottom right you can what type of file VSCode thinks you are working in, it also shows a number, most likely 3.12.x if you are following this course in 2025. This number is the python version of the interpreter that is now running, more on this later. In the left there is a column with some buttons. These buttons are, from top to bottom, for: | ||
| You can run the full code by pressing the play button on the top left. Select Run Python File in Terminal to see the output in the Terminal window. | ||
|
|
||
| When you do this, a terminal pops up, showing the output of the file. In Positron we run code per file. |
There was a problem hiding this comment.
Maybe mention that in python running code pre file is the the normal way to go, but positron allows for running line by line.
| **Warning for students taking the course**: VSCode comes with advanced integration of generative AI. It is recommended to not make use of GenAI while learning to code. Struggling through how to get a script working is how you learn, and that is what this course is about. Generating the correct result will not teach you anything. | ||
| **Warning for students taking the course**: Positron comes with advanced integration of generative AI. It is recommended to not make use of GenAI while learning to code. Struggling through how to get a script working is how you learn, and that is what this course is about. Generating the correct result will not teach you anything. | ||
|
|
||
| It is recommended to turn off automatic features that copilot offers. You can do this by |
There was a problem hiding this comment.
Also include how to turn off posit assistent
| If you press `ctrl` and click on the function in `main.py` you will open the function definition. This is very useful when navigating through a large project. | ||
|
|
||
| ### Environments in VSCode | ||
| ### Environments in Positron |
There was a problem hiding this comment.
Instead of introducing setting the interpreter earlier, we can also just get them to run a script there in the most easy way and introduce that here.
| @@ -304,7 +318,7 @@ If `(geotest)` is visible before the active line in the terminal the environment | |||
|
|
|||
| Now, you might wonder how you will write code without being able to inspect what is going on. And don't be afraid there are ways to help you. The *debugger* and the interactive *REPL* _(Read-Evaluate-Print Loop)_ are tools developers use to make developing easier. Firstly the debugger. The debugger is a way of running code where you can set breakpoints and inspect the state of the code and all the variables and objects in memory. While at a checkpoint you can manipulate variables, print them and test small pieces of code on them to figure out how to proceed. From the checkpoint it is possible to proceed line by line, stepping into your function or imported packages to get a good understanding of what is happening and often identifying issues. Sounds good right? | |||
There was a problem hiding this comment.
This might be rewritten a bit more, since line by line is an option in positron. the REPL is nto that relevant anymore, but maybe introducing the debugger a bit more detailed is useful.
There was a problem hiding this comment.
I really dont use the debugger or REPL, so maybe its best if you take a look over this Arno and decide what is best to keep and what to explain in more detail
There was a problem hiding this comment.
Note: REPL is also used the day after in the tutorial Python Programming
| Now that we know how to set up an environment and run code, lets use this new knowledge and run some Python code. Again, during this course advise you to code in VSCode, as this IDE is the recommended IDE for the Python part of this course. | ||
| Now that we know how to set up an environment and run code, lets use this new knowledge and run some Python code. Again, during this course advise you to code in Positron, as this IDE is the recommended IDE for the Python part of this course. | ||
|
|
||
| Create a directory structure for this tutorial using the terminal: |
There was a problem hiding this comment.
Also use pixi init after this
| Create a new Python script and save it. | ||
|
|
||
| Important to note: for compatibility, it is best to install packages from the same channel as much as possible. Given that packages in the file `refresher.yaml` are installed from the `conda-forge` channel, it is wise to use this same channel when you want to install additional packages in your environment. | ||
| Important to note: for compatibility, it is best to install packages from the same channel as much as possible. Given that packages in the file `refresher.toml` are installed from the `conda-forge` channel, it is wise to use this same channel when you want to install additional packages in your environment. |
There was a problem hiding this comment.
less relevant for pixi then for conda, just delete for clarity
Co-authored-by: Arno Timmer <199092967+awurno@users.noreply.github.com>
Co-authored-by: Arno Timmer <199092967+awurno@users.noreply.github.com>
I have replaced the VSCode parts with Positron. The conda installations have been replaced with the pixi intsallations.
I think only two screenshots actually need replacement, the rest (all the Git part) is really the same as the previous one (even if in VSCode).
I also felt like reordering bits of code/text, as it was clearer to me.
I have added minor things such as the command ls -a in 'using pixi' to see all files (as ls only does not show all the hidden files).
Things to note:
the cow.py example gives a warning (only the first time you run it).
Disable GitHub Copilot: disabling the settings for GitHub Copilot: Enable should be enough? When looking for GitHub Copilot Chat a loooot of settings are found.
The Extensions are already installed in the VM. I changed the text to make the students note that these are installed, but no installments are done.
Positron raises an error when calling a package MyPackage, it suggests calling it my_package and solves the problem.
I removed the extensions.png image as it was the same as main.py ? no need to repeat twice?